Replace init.vim with init.lua, better structure of lua files under lua directory

This commit is contained in:
Evie Litherland-Smith 2022-11-01 15:15:15 +00:00
parent d2e33f4c33
commit 04e81ff4be
15 changed files with 162 additions and 139 deletions

0
.gitmodules vendored
View file

View file

@ -1,12 +0,0 @@
require 'config_gitsigns'
require 'config_lualine'
require 'config_nightfox'
require 'config_nvim-tree'
require 'config_sniprun'
require 'config_tabby'
require 'config_telescope'
require 'config_toggleterm'
require('trouble').setup()
require('fidget').setup()
require('hop').setup()

104
init.lua
View file

@ -1,3 +1,107 @@
vim.cmd[[
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
" Make sure you use single quotes
Plug 'nvim-lua/plenary.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'j-hui/fidget.nvim'
Plug 'sonph/onehalf', {'rtp': 'vim/'}
Plug 'EdenEast/nightfox.nvim'
Plug 'mileszs/ack.vim'
Plug 'stevearc/aerial.nvim'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-commentary'
" Plug 'lewis6991/gitsigns.vim'
Plug 'https://github.com/lewis6991/gitsigns.nvim.git'
Plug 'nvim-lualine/lualine.nvim'
Plug 'nanozuki/tabby.nvim'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'kyazdani42/nvim-tree.lua'
Plug 'christoomey/vim-tmux-navigator'
Plug 'akinsho/toggleterm.nvim', {'tag' : 'v2.*'}
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/cmp-nvim-lua'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.0' }
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
Plug 'rcarriga/nvim-notify'
Plug 'michaelb/sniprun', {'do': 'bash install.sh'}
Plug 'phaazon/hop.nvim'
Plug 'folke/trouble.nvim'
" Initialize plugin system
call plug#end()
]]
vim.notify = require("notify")
require 'keymaps'
require 'config_lsp'
require 'config_plugins'
-- TODO convert to lua
vim.cmd[[
" set runtimepath^=~/.vim runtimepath+=~/.vim/after
" let &packpath = &runtimepath
" source ~/.vimrc
let g:loaded = 1
let g:loaded_netrwPlugin = 1
let &t_ut='' " For kitty background colour support
set updatetime=500
set mouse=nv
let g:python3_host_prog = '~/.pyenv/versions/neovim3/bin/python'
if exists('+termguicolors')
set termguicolors
endif
colorscheme nightfox
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
set number
set relativenumber
set listchars=trail:.,tab:>_
set list
set wrap
set linebreak
set autoread
au BufRead,BufNewFile *.ipynb setlocal filetype=json
au BufRead,BufNewFile *.md setlocal spell
au BufRead,BufNewFile *.code-workspace setlocal filetype=json
au BufRead,BufNewFile *.csv setlocal nowrap
au BufRead,BufNewFile *.service[a-zA-Z0-9]* setlocal filetype=systemd
au TermOpen * setlocal nonumber norelativenumber
syntax on
if &diff
highlight! link DiffText MatchParen
endif
au OptionSet diff highlight! link DiffText MatchParen
set expandtab
set autoindent
set smartindent
filetype plugin indent on
set splitbelow
set splitright
]]

127
init.vim
View file

@ -1,127 +0,0 @@
" set runtimepath^=~/.vim runtimepath+=~/.vim/after
" let &packpath = &runtimepath
" source ~/.vimrc
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
" Make sure you use single quotes
Plug 'nvim-lua/plenary.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'j-hui/fidget.nvim'
Plug 'sonph/onehalf', {'rtp': 'vim/'}
Plug 'EdenEast/nightfox.nvim'
Plug 'mileszs/ack.vim'
Plug 'stevearc/aerial.nvim'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-commentary'
" Plug 'lewis6991/gitsigns.vim'
Plug 'https://github.com/lewis6991/gitsigns.nvim.git'
Plug 'nvim-lualine/lualine.nvim'
Plug 'nanozuki/tabby.nvim'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'kyazdani42/nvim-tree.lua'
Plug 'christoomey/vim-tmux-navigator'
Plug 'akinsho/toggleterm.nvim', {'tag' : 'v2.*'}
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/cmp-nvim-lua'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.0' }
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
Plug 'rcarriga/nvim-notify'
Plug 'michaelb/sniprun', {'do': 'bash install.sh'}
Plug 'phaazon/hop.nvim'
Plug 'folke/trouble.nvim'
" Initialize plugin system
call plug#end()
let g:mapleader=" "
let g:loaded = 1
let g:loaded_netrwPlugin = 1
let &t_ut='' " For kitty background colour support
set updatetime=500
set mouse=nv
let g:python3_host_prog = '~/.pyenv/versions/neovim3/bin/python'
if exists('+termguicolors')
set termguicolors
endif
colorscheme nightfox
luafile ~/.vim/init.lua
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
set number
set relativenumber
set listchars=trail:.,tab:>_
set list
set wrap
set linebreak
set autoread
au BufRead,BufNewFile *.ipynb setlocal filetype=json
au BufRead,BufNewFile *.md setlocal spell
au BufRead,BufNewFile *.code-workspace setlocal filetype=json
au BufRead,BufNewFile *.csv setlocal nowrap
au BufRead,BufNewFile *.service[a-zA-Z0-9]* setlocal filetype=systemd
au TermOpen * setlocal nonumber norelativenumber
syntax on
if &diff
highlight! link DiffText MatchParen
endif
au OptionSet diff highlight! link DiffText MatchParen
set expandtab
set autoindent
set smartindent
filetype plugin indent on
imap jk <Esc>
command Bd b# | bd #
command! BufOnly silent! execute "%bd|e#|bd#"
nnoremap <leader>a :Ack!<Space>
nnoremap <leader>sr :SnipRun<cr>
nnoremap <leader>; <cmd>Telescope builtin<cr>
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fr <cmd>Telescope resume<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>fk <cmd>Telescope aerial<cr>
nnoremap <leader>fd <cmd>Telescope lsp_document_symbols<cr>
nnoremap <leader>fe <cmd>Telescope diagnostics<cr>
nnoremap <leader>fn <cmd>Telescope notify<cr>
nnoremap <leader>ft <cmd>Telescope treesitter<cr>
nnoremap <leader>fz <cmd>Telescope current_buffer_fuzzy_find<cr>
nnoremap <leader>fgr <cmd>Telescope live_grep<cr>
nnoremap <leader>fgf <cmd>Telescope git_files<cr>
nnoremap <leader>fgs <cmd>Telescope git_status<cr>
nnoremap <leader>fgb <cmd>Telescope git_branches<cr>
nnoremap <leader>hl <cmd>HopLine<cr>
nnoremap <leader>hw <cmd>HopWord<cr>
nnoremap <leader>nt <cmd>NvimTreeToggle<cr>
nnoremap <leader>nf <cmd>NvimTreeFindFile<cr>
nnoremap [g <cmd>Gitsigns prev_hunk<cr>
nnoremap ]g <cmd>Gitsigns next_hunk<cr>
set splitbelow
set splitright

12
lua/config_plugins.lua Normal file
View file

@ -0,0 +1,12 @@
require 'plugins/config_gitsigns'
require 'plugins/config_lualine'
require 'plugins/config_nightfox'
require 'plugins/config_nvim-tree'
require 'plugins/config_sniprun'
require 'plugins/config_tabby'
require 'plugins/config_telescope'
require 'plugins/config_toggleterm'
require('trouble').setup()
require('fidget').setup()
require('hop').setup()

46
lua/keymaps.lua Normal file
View file

@ -0,0 +1,46 @@
function map(mode, shortcut, command)
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
end
function nmap(shortcut, command)
map('n', shortcut, command)
end
function imap(shortcut, command)
map('i', shortcut, command)
end
vim.g.mapleader=' '
-- Misc
imap('jk','<Esc>')
nmap('<leader>a', ':Ack!<Space>')
nmap('<leader>sr', ':SnipRun<cr>')
-- Telescope
nmap('<leader>;', '<cmd>Telescope builtin<cr>')
nmap('<leader>ff', '<cmd>Telescope find_files<cr>')
nmap('<leader>fr', '<cmd>Telescope resume<cr>')
nmap('<leader>fb', '<cmd>Telescope buffers<cr>')
nmap('<leader>fh', '<cmd>Telescope help_tags<cr>')
nmap('<leader>fk', '<cmd>Telescope aerial<cr>')
nmap('<leader>fd', '<cmd>Telescope lsp_document_symbols<cr>')
nmap('<leader>fe', '<cmd>Telescope diagnostics<cr>')
nmap('<leader>fn', '<cmd>Telescope notify<cr>')
nmap('<leader>ft', '<cmd>Telescope treesitter<cr>')
nmap('<leader>fz', '<cmd>Telescope current_buffer_fuzzy_find<cr>')
nmap('<leader>fgr', '<cmd>Telescope live_grep<cr>')
nmap('<leader>fgf', '<cmd>Telescope git_files<cr>')
nmap('<leader>fgs', '<cmd>Telescope git_status<cr>')
nmap('<leader>fgb', '<cmd>Telescope git_branches<cr>')
-- Hop
nmap('<leader>hl', '<cmd>HopLine<cr>')
nmap('<leader>hw', '<cmd>HopWord<cr>')
-- Nvim-tree
nmap('<leader>nt', '<cmd>NvimTreeToggle<cr>')
nmap('<leader>nf', '<cmd>NvimTreeFindFile<cr>')
-- Gitsigns
nmap('[g', '<cmd>Gitsigns prev_hunk<cr>')
nmap(']g', '<cmd>Gitsigns next_hunk<cr>')