nvim: Refactor configuration and start moving to lua
This commit is contained in:
parent
8c69639144
commit
cb16ddec0c
17 changed files with 311 additions and 349 deletions
4
nvim/.config/nvim/after/plugin/better-whitespace.vim
Normal file
4
nvim/.config/nvim/after/plugin/better-whitespace.vim
Normal file
|
@ -0,0 +1,4 @@
|
|||
let g:better_whitespace_enabled = 1
|
||||
let g:strip_whitespace_on_save = 1
|
||||
let g:better_whitespace_operator = ''
|
||||
let g:strip_whitespace_confirm = 0
|
4
nvim/.config/nvim/after/plugin/diagnostic.vim
Normal file
4
nvim/.config/nvim/after/plugin/diagnostic.vim
Normal file
|
@ -0,0 +1,4 @@
|
|||
let g:diagnostic_enable_virtual_text = 0
|
||||
let g:diagnostic_show_sign = 1
|
||||
let g:diagnostic_auto_popup_while_jump = 1
|
||||
let g:diagnostic_insert_delay = 1
|
9
nvim/.config/nvim/after/plugin/floaterm.vim
Normal file
9
nvim/.config/nvim/after/plugin/floaterm.vim
Normal file
|
@ -0,0 +1,9 @@
|
|||
let g:floaterm_open_in_root = 0
|
||||
let g:floaterm_position = 'center'
|
||||
let g:floaterm_width = 0.8
|
||||
let g:floaterm_height = 0.8
|
||||
let g:floaterm_winblend = 0
|
||||
let g:floaterm_borderchars = ['─', '│', '─', '│', '╭', '╮', '╯', '╰']
|
||||
|
||||
nnoremap <silent> <C-z> :FloatermToggle<Enter>
|
||||
tnoremap <silent> <C-z> <C-\><C-n>:FloatermToggle<Enter>
|
|
@ -1,3 +1,6 @@
|
|||
let $FZF_DEFAULT_OPTS="--layout=reverse --bind \"Ctrl-n:preview-down,Ctrl-p:preview-up\""
|
||||
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 } }
|
||||
|
||||
nnoremap <Leader>b :Buffers<CR>
|
||||
nnoremap <Leader>B :History<CR>
|
||||
nnoremap <Leader>/ :GFiles?<CR>
|
||||
|
|
1
nvim/.config/nvim/after/plugin/rainbow.vim
Normal file
1
nvim/.config/nvim/after/plugin/rainbow.vim
Normal file
|
@ -0,0 +1 @@
|
|||
let g:rainbow_active = 1
|
2
nvim/.config/nvim/after/plugin/togglelist.vim
Normal file
2
nvim/.config/nvim/after/plugin/togglelist.vim
Normal file
|
@ -0,0 +1,2 @@
|
|||
nnoremap qt :call ToggleQuickfixList()<CR>
|
||||
nnoremap Lt :call ToggleLocationList()<CR>
|
3
nvim/.config/nvim/after/plugin/vimtex.vim
Normal file
3
nvim/.config/nvim/after/plugin/vimtex.vim
Normal file
|
@ -0,0 +1,3 @@
|
|||
let g:vimtex_view_general_viewer = 'qpdfview'
|
||||
let g:vimtex_view_general_options = '--unique @pdf\#src:@tex:@line:@col'
|
||||
let g:vimtex_view_general_options_latexmk = '--unique'
|
4
nvim/.config/nvim/after/plugin/which_key.vim
Normal file
4
nvim/.config/nvim/after/plugin/which_key.vim
Normal file
|
@ -0,0 +1,4 @@
|
|||
let g:which_key_use_floating_win = 1
|
||||
|
||||
nnoremap <silent> <Leader> :<C-U>WhichKey '<Space>'<CR>
|
||||
nnoremap <silent> <LocalLeader> :<C-U>WhichKey ','<CR>
|
7
nvim/.config/nvim/after/plugin/workspace.vim
Normal file
7
nvim/.config/nvim/after/plugin/workspace.vim
Normal file
|
@ -0,0 +1,7 @@
|
|||
let g:workspace_session_directory = $HOME . '/.vim/session/'
|
||||
let g:workspace_undodir = $HOME . '/.vim/undodir'
|
||||
let g:workspace_autosave = 0
|
||||
let g:workspace_autosave_ignore = ['gitcommit', 'qf', 'tagbar']
|
||||
let g:workspace_session_disable_on_args = 1
|
||||
|
||||
nnoremap <Leader>ps :ToggleWorkspace<CR>
|
|
@ -1,46 +0,0 @@
|
|||
augroup terminal_job
|
||||
au!
|
||||
au TermOpen * startinsert
|
||||
au TermOpen * setlocal listchars= nonumber norelativenumber
|
||||
augroup END
|
||||
|
||||
augroup ResizeWindowsProportionally
|
||||
au!
|
||||
autocmd VimResized * :wincmd =
|
||||
augroup END
|
||||
|
||||
augroup ToggleSearchHighlighting
|
||||
autocmd!
|
||||
autocmd InsertEnter * setlocal nohlsearch
|
||||
augroup END
|
||||
|
||||
augroup UserStatusline
|
||||
autocmd!
|
||||
autocmd BufEnter,WinEnter,TermOpen * setlocal statusline=%!ActiveStatus()
|
||||
autocmd WinLeave * setlocal statusline=%!PassiveStatus()
|
||||
autocmd ColorScheme * hi User1 guifg=DarkRed guibg=Black
|
||||
autocmd ColorScheme * hi User2 guifg=White guibg=Black
|
||||
autocmd ColorScheme * hi User3 guifg=Cyan guibg=Black
|
||||
autocmd ColorScheme * hi User4 guifg=Orange guibg=Black
|
||||
autocmd ColorScheme * hi User5 guifg=Red guibg=Black
|
||||
autocmd ColorScheme * hi User6 guifg=Gray guibg=Black
|
||||
autocmd ColorScheme * hi User7 guifg=Gray guibg=Black
|
||||
autocmd ColorScheme * hi User8 guifg=DarkYellow guibg=Black
|
||||
augroup END
|
||||
|
||||
augroup LuaHighlight
|
||||
autocmd!
|
||||
autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank("IncSearch", 2000)
|
||||
augroup END
|
||||
|
||||
augroup Scrollbar
|
||||
autocmd!
|
||||
autocmd BufEnter * silent! lua require('scrollbar').show()
|
||||
autocmd BufLeave * silent! lua require('scrollbar').clear()
|
||||
|
||||
autocmd CursorMoved * silent! lua require('scrollbar').show()
|
||||
autocmd VimResized * silent! lua require('scrollbar').show()
|
||||
|
||||
autocmd FocusGained * silent! lua require('scrollbar').show()
|
||||
autocmd FocusLost * silent! lua require('scrollbar').clear()
|
||||
augroup END
|
|
@ -1,110 +0,0 @@
|
|||
" Set up leaders
|
||||
let mapleader="\<SPACE>"
|
||||
let maplocalleader=","
|
||||
|
||||
set shada="NONE" " Prevent SHADA files from being generated or read
|
||||
set laststatus=2 " Always show status bar
|
||||
set updatetime=100 " Let plugins show effects after 100ms
|
||||
set mouse-=a " Disable mouse click to go to position
|
||||
set encoding=utf-8
|
||||
set exrc " Allow loading local .nvimrc files
|
||||
set secure " Disallow use of autocmd, shell and write in local rc
|
||||
set showcmd " Show (partial) command in status line.
|
||||
set showmatch " Show matching brackets.
|
||||
set ruler " Show the line and column numbers of the cursor.
|
||||
set formatoptions+=o " Continue comment marker in new lines.
|
||||
set formatoptions+=j " Delete comment character when joining commented lines
|
||||
set textwidth=78 " Hard-wrap long lines as you type them.
|
||||
set autoindent " Copy indent from current line when starting a new line
|
||||
set noerrorbells " No beeps.
|
||||
set modeline " Enable modeline.
|
||||
set linespace=0 " Set line-spacing to minimum.
|
||||
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
|
||||
set noshowmode " Because of neovim's cursor shape
|
||||
set splitbelow " Horizontal split below current.
|
||||
set splitright " Vertical split to right of current.
|
||||
set nobackup " no backup files
|
||||
set nowritebackup " only in case you don't want a backup file while editing
|
||||
set noswapfile " no swap files
|
||||
set nofoldenable " Open folds by default
|
||||
set undofile " Enable undo persistence across sessions
|
||||
set hidden
|
||||
set noautochdir
|
||||
set hlsearch
|
||||
set nostartofline " Do not jump to first character with page commands.
|
||||
set ignorecase " Make searching case insensitive
|
||||
set smartcase " ... unless the query has capital letters.
|
||||
set magic " Use 'magic' patterns (extended regular expressions).
|
||||
set autoread " Autoload file if it changes on disk
|
||||
set termguicolors " Enable colors for terminal
|
||||
set completeopt-=menu
|
||||
set completeopt-=longest " Don't insert the longest common text
|
||||
set completeopt-=preview " Hide the documentation preview window
|
||||
set completeopt+=menuone " Show the completions UI even with only 1 item
|
||||
set completeopt+=noinsert " Don't insert text automatically
|
||||
set completeopt+=noselect " Do not select a match in the menu
|
||||
" Required for vim-workspace
|
||||
" See https://github.com/thaerkh/vim-workspace/issues/11
|
||||
set sessionoptions-=blank
|
||||
set fileformat=unix
|
||||
set inccommand=split
|
||||
set switchbuf=useopen
|
||||
set backspace=indent,eol,start
|
||||
set scrolloff=3 " Show next 3 lines while scrolling.
|
||||
set sidescrolloff=5 " Show next 5 columns while side-scrolling.
|
||||
set diffopt=filler,internal,algorithm:histogram,indent-heuristic
|
||||
|
||||
" Wild menu
|
||||
set wildmenu
|
||||
set wildmode=longest:full,full
|
||||
set wildoptions=pum
|
||||
set pumblend=30
|
||||
set wildignore=*.o,*.obj,*~,*.exe,*.a,*.pdb,*.lib
|
||||
set wildignore+=__pycache__,.stversions,*.spl,*.out,%*
|
||||
set wildignore+=*.so,*.dll,*.swp,*.egg,*.jar,*.class,*.pyc,*.pyo,*.bin,*.dex
|
||||
set wildignore+=*.zip,*.7z,*.rar,*.gz,*.tar,*.gzip,*.bz2,*.tgz,*.xz
|
||||
set wildignore+=*DS_Store*,*.ipch
|
||||
set wildignore+=*.gem
|
||||
set wildignore+=*.png,*.jpg,*.gif,*.bmp,*.tga,*.pcx,*.ppm,*.img,*.iso
|
||||
set wildignore+=*.so,*.swp,*.zip,*/.Trash/**,*.pdf,*.dmg,*/.rbenv/**
|
||||
set wildignore+=*/.nx/**,*.app,*.git,.git
|
||||
set wildignore+=*.wav,*.mp3,*.ogg,*.pcm
|
||||
set wildignore+=*.mht,*.suo,*.sdf,*.jnlp
|
||||
set wildignore+=*.chm,*.epub,*.pdf,*.mobi,*.ttf
|
||||
set wildignore+=*.mp4,*.avi,*.flv,*.mov,*.mkv,*.swf,*.swc
|
||||
set wildignore+=*.ppt,*.pptx,*.docx,*.xlt,*.xls,*.xlsx,*.odt,*.wps
|
||||
set wildignore+=*.msi,*.crx,*.deb,*.vfd,*.apk,*.ipa,*.bin,*.msu
|
||||
set wildignore+=*.gba,*.sfc,*.078,*.nds,*.smd,*.smc
|
||||
set wildignore+=*.linux2,*.win32,*.darwin,*.freebsd,*.linux,*.android
|
||||
|
||||
" We do this to prevent the loading of the system fzf.vim plugin. This is
|
||||
" present at least on Arch/Manjaro
|
||||
set rtp-=/usr/share/vim/vimfiles
|
||||
|
||||
" Disable providers we do not give a shit about
|
||||
let g:loaded_python3_provider = 0
|
||||
let g:loaded_python_provider = 0
|
||||
let g:loaded_ruby_provider = 0
|
||||
let g:loaded_perl_provider = 0
|
||||
let g:loaded_node_provider = 0
|
||||
|
||||
" Disable some in built plugins completely
|
||||
let g:loaded_netrw = 1
|
||||
let g:loaded_netrwPlugin = 1
|
||||
let g:loaded_matchparen = 1
|
||||
let g:loaded_matchit = 1
|
||||
let g:loaded_2html_plugin = 1
|
||||
let g:loaded_getscriptPlugin = 1
|
||||
let g:loaded_gzip = 1
|
||||
let g:loaded_logipat = 1
|
||||
let g:loaded_rrhelper = 1
|
||||
let g:loaded_spellfile_plugin = 1
|
||||
let g:loaded_tarPlugin = 1
|
||||
let g:loaded_vimballPlugin = 1
|
||||
let g:loaded_zipPlugin = 1
|
||||
|
||||
" Add the in built Cfilter plugin. Replaces QFGrep.
|
||||
packadd cfilter
|
||||
|
||||
" Colorscheme
|
||||
colorscheme yolokai
|
|
@ -89,15 +89,11 @@ Plug 'martinda/Jenkinsfile-vim-syntax'
|
|||
|
||||
call plug#end()
|
||||
|
||||
let g:vim_home = get(g:, 'vim_home', expand('~/.config/nvim/'))
|
||||
let config_list = [
|
||||
\ 'autocmd.vim',
|
||||
\ 'config.vim',
|
||||
\ 'keymappings.vim',
|
||||
\ 'plugin_settings.vim',
|
||||
\]
|
||||
for files in config_list
|
||||
for f in glob(g:vim_home.files, 1, 1)
|
||||
exec 'source' f
|
||||
endfor
|
||||
endfor
|
||||
" Set up leader keys
|
||||
let mapleader="\<SPACE>"
|
||||
let maplocalleader=","
|
||||
" Use Tab & S-Tab instead of C-g and C-t for incsearch
|
||||
cno <expr> <Tab> getcmdtype() =~ '[?/]' ? '<C-g>' : feedkeys('<Tab>', 'int')[1]
|
||||
cno <expr> <S-Tab> getcmdtype() =~ '[?/]' ? '<C-t>' : feedkeys('<S-Tab>', 'int')[1]
|
||||
|
||||
lua require 'init'
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
" Remap escape keys to something usable on home row
|
||||
inoremap jk <Esc>
|
||||
cnoremap jk <C-C>
|
||||
inoremap <Esc> <Nop>
|
||||
cnoremap <Esc> <Nop>
|
||||
" Use Q to execute default register.
|
||||
nnoremap Q <Nop>
|
||||
|
||||
" Save
|
||||
nnoremap <Leader>w <Esc>:w<CR>
|
||||
" Search and Replace
|
||||
nnoremap c. :%s//g<Left><Left>
|
||||
nnoremap <Leader>c. :%s/\<<C-r><C-w>\>//g<Left><Left>
|
||||
" Quit
|
||||
nnoremap <Leader>x <Esc>:x<CR>
|
||||
nnoremap <Leader>q <Esc>:q<CR>
|
||||
nnoremap <Leader>Q <Esc>:qa<CR>
|
||||
" Navigate buffers
|
||||
nnoremap [b :bprevious<CR>
|
||||
nnoremap ]b :bnext<CR>
|
||||
nnoremap [B :bfirst<CR>
|
||||
nnoremap ]B :blast<CR>
|
||||
" Reload buffer
|
||||
nnoremap <Leader>e :e<CR>
|
||||
nnoremap <Leader>E :bufdo e<CR>
|
||||
" Tab navigation
|
||||
nnoremap <Leader>tp :tabprevious<CR>
|
||||
nnoremap <Leader>tn :tabnext<CR>
|
||||
nnoremap <Leader>tf :tabfirst<CR>
|
||||
nnoremap <Leader>tl :tablast<CR>
|
||||
nnoremap <Leader>tN :tabnew<CR>
|
||||
nnoremap <Leader>tc :tabclose<CR>
|
||||
" For tags
|
||||
nnoremap [t :tprevious<CR>
|
||||
nnoremap ]t :tNext<CR>
|
||||
nnoremap [T :tfirst<CR>
|
||||
nnoremap ]T :tlast<CR>
|
||||
nnoremap <Leader>ts :exec("tselect ".expand("<cword>"))<CR>
|
||||
" For workspace
|
||||
nnoremap <Leader>ps :ToggleWorkspace<CR>
|
||||
" Quickfix & Location list mappings
|
||||
nnoremap qo :copen<CR>
|
||||
nnoremap qc :cclose<CR>
|
||||
nnoremap [q :cprevious<CR>
|
||||
nnoremap ]q :cnext<CR>
|
||||
nnoremap [Q :cfirst<CR>
|
||||
nnoremap ]Q :clast<CR>
|
||||
nnoremap q* :Ggrep! <cword><CR>
|
||||
nnoremap qs :Ggrep!<SPACE>
|
||||
nnoremap qt :call ToggleQuickfixList()<CR>
|
||||
nnoremap Lo :lopen<CR>
|
||||
nnoremap Lc :lclose<CR>
|
||||
nnoremap [l :lprevious<CR>
|
||||
nnoremap ]l :lnext<CR>
|
||||
nnoremap [L :lfirst<CR>
|
||||
nnoremap ]L :llast<CR>
|
||||
nnoremap L* :Glgrep! <cword><CR>
|
||||
nnoremap Ls :Glgrep!<SPACE>
|
||||
nnoremap Lt :call ToggleLocationList()<CR>
|
||||
" Preview tags
|
||||
nnoremap pt :ptag <C-R><C-W><CR>
|
||||
nnoremap [p :ptprevious<CR>
|
||||
nnoremap ]p :ptnext<CR>
|
||||
nnoremap po :ppop<CR>
|
||||
nnoremap pc :pc<CR>
|
||||
nnoremap pi :psearch <C-R><C-W><CR>
|
||||
" Short cuts for setting fold methods
|
||||
nnoremap zmi :set foldmethod=indent<CR>
|
||||
nnoremap zmm :set foldmethod=manual<CR>
|
||||
nnoremap zme :set foldmethod=expr<CR>
|
||||
nnoremap zmk :set foldmethod=marker<CR>
|
||||
nnoremap zms :set foldmethod=syntax<CR>
|
||||
|
||||
" Key Bindings to help with terminal mode
|
||||
tnoremap jk <C-\><C-n>
|
||||
nnoremap <silent> <C-z> :FloatermToggle<Enter>
|
||||
tnoremap <silent> <C-z> <C-\><C-n>:FloatermToggle<Enter>
|
||||
|
||||
" Key bindings to move between window splits
|
||||
for key in range(0, 9)
|
||||
execute 'nnoremap <Space>'.key key.'<C-w>w'
|
||||
endfor
|
||||
|
||||
" Disable Arrow Keys
|
||||
inoremap <Up> <NOP>
|
||||
inoremap <Down> <NOP>
|
||||
inoremap <Left> <NOP>
|
||||
inoremap <Right> <NOP>
|
||||
noremap <Up> <NOP>
|
||||
noremap <Down> <NOP>
|
||||
noremap <Left> <NOP>
|
||||
noremap <Right> <NOP>
|
||||
|
||||
" Whick key
|
||||
nnoremap <silent> <Leader> :<C-U>WhichKey '<Space>'<CR>
|
||||
nnoremap <silent> <LocalLeader> :<C-U>WhichKey ','<CR>
|
||||
|
||||
" Tag helpers
|
||||
nnoremap <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
|
||||
nnoremap <A-]> :sp <CR>:exec("tag ".expand("<cword>"))<CR>
|
||||
|
||||
" Use Tab & S-Tab instead of C-g and C-t for incsearch
|
||||
cno <expr> <Tab> getcmdtype() =~ '[?/]' ? '<C-g>' : feedkeys('<Tab>', 'int')[1]
|
||||
cno <expr> <S-Tab> getcmdtype() =~ '[?/]' ? '<C-t>' : feedkeys('<S-Tab>', 'int')[1]
|
||||
nnoremap <silent> <Leader>n :nohlsearch<CR>
|
||||
|
||||
" Move across wrapped lines like regular lines
|
||||
" Go to the first non-blank character of a line
|
||||
noremap 0 ^
|
||||
" Just in case you need to go to the very beginning of a line
|
||||
noremap ^ 0
|
||||
" Centre the window on each search movement
|
||||
nnoremap n nzz
|
||||
nnoremap N Nzz
|
||||
vnoremap n nzz
|
||||
vnoremap N Nzz
|
||||
|
||||
" Make dot work on visually selected lines
|
||||
vnoremap . :norm.<CR>
|
||||
" Go to the last file we changed
|
||||
nnoremap <BS> <C-^>
|
55
nvim/.config/nvim/lua/autocmd.lua
Normal file
55
nvim/.config/nvim/lua/autocmd.lua
Normal file
|
@ -0,0 +1,55 @@
|
|||
local vim = vim
|
||||
local api = vim.api
|
||||
|
||||
--- This function is taken from https://github.com/norcalli/nvim_utils
|
||||
function nvim_create_augroups(definitions)
|
||||
for group_name, definition in pairs(definitions) do
|
||||
api.nvim_command('augroup '..group_name)
|
||||
api.nvim_command('autocmd!')
|
||||
for _, def in ipairs(definition) do
|
||||
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
|
||||
api.nvim_command(command)
|
||||
end
|
||||
api.nvim_command('augroup END')
|
||||
end
|
||||
end
|
||||
|
||||
local autocmds = {
|
||||
terminal_job = {
|
||||
{ "TermOpen", "*", "startinsert" };
|
||||
{ "TermOpen", "*", "setlocal listchars= nonumber norelativenumber" };
|
||||
};
|
||||
resize_windows_proportionally = {
|
||||
{ "VimResized", "*", ":wincmd =" };
|
||||
};
|
||||
toggle_search_highlighting = {
|
||||
{ "InsertEnter", "*", "setlocal nohlsearch" };
|
||||
};
|
||||
lua_highlight = {
|
||||
{ "TextYankPost", "*", "silent! lua require'vim.highlight'.on_yank(\"IncSearch\", 2000)" };
|
||||
};
|
||||
scrollbar = {
|
||||
{ "BufEnter", "*", "silent! lua require('scrollbar').show()" };
|
||||
{ "BufLeave", "*", "silent! lua require('scrollbar').clear()" };
|
||||
|
||||
{ "CursorMoved", "*", "silent! lua require('scrollbar').show()" };
|
||||
{ "VimResized", "*", "silent! lua require('scrollbar').show()" };
|
||||
|
||||
{ "FocusGained", "*", "silent! lua require('scrollbar').show()" };
|
||||
{ "FocusLost", "*", "silent! lua require('scrollbar').clear()" };
|
||||
};
|
||||
user_status_line = {
|
||||
{ "BufEnter,WinEnter,TermOpen", "*", "setlocal statusline=%!ActiveStatus()" };
|
||||
{ "WinLeave", "*", "setlocal statusline=%!PassiveStatus()" };
|
||||
{ "ColorScheme", "*", "hi User1 guifg=DarkRed guibg=Black" };
|
||||
{ "ColorScheme", "*", "hi User2 guifg=White guibg=Black" };
|
||||
{ "ColorScheme", "*", "hi User3 guifg=Cyan guibg=Black" };
|
||||
{ "ColorScheme", "*", "hi User4 guifg=Orange guibg=Black" };
|
||||
{ "ColorScheme", "*", "hi User5 guifg=Red guibg=Black" };
|
||||
{ "ColorScheme", "*", "hi User6 guifg=Gray guibg=Black" };
|
||||
{ "ColorScheme", "*", "hi User7 guifg=Gray guibg=Black" };
|
||||
{ "ColorScheme", "*", "hi User8 guifg=DarkYellow guibg=Black" };
|
||||
};
|
||||
}
|
||||
|
||||
nvim_create_augroups(autocmds)
|
98
nvim/.config/nvim/lua/init.lua
Normal file
98
nvim/.config/nvim/lua/init.lua
Normal file
|
@ -0,0 +1,98 @@
|
|||
-- Global vim options
|
||||
vim.o.laststatus = 2
|
||||
vim.o.updatetime = 100
|
||||
vim.o.scrolloff = 3
|
||||
vim.o.sidescrolloff = 5
|
||||
vim.o.textwidth = 78
|
||||
vim.o.linespace = 0
|
||||
vim.o.exrc = true
|
||||
vim.o.secure = true
|
||||
vim.o.showcmd = true
|
||||
vim.o.showmatch = true
|
||||
vim.o.ruler = true
|
||||
vim.o.autoindent = true
|
||||
vim.o.errorbells = false
|
||||
vim.o.modeline = true
|
||||
vim.o.joinspaces = false
|
||||
vim.o.showmode = false
|
||||
vim.o.splitbelow = true
|
||||
vim.o.splitright = true
|
||||
vim.o.backup = false
|
||||
vim.o.writebackup = false
|
||||
vim.o.swapfile = false
|
||||
vim.o.foldenable = false
|
||||
vim.o.undofile = true
|
||||
vim.o.hidden = true
|
||||
vim.o.autochdir = false
|
||||
vim.o.hlsearch = true
|
||||
vim.o.startofline = false
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
vim.o.magic = true
|
||||
vim.o.autoread = true
|
||||
vim.o.termguicolors = true
|
||||
vim.o.fileformat = 'unix'
|
||||
vim.o.inccommand = 'split'
|
||||
vim.o.switchbuf = 'useopen'
|
||||
vim.o.encoding = 'utf-8'
|
||||
|
||||
-- Disable providers we do not give a shit about
|
||||
vim.g.loaded_python3_provider = 0
|
||||
vim.g.loaded_python_provider = 0
|
||||
vim.g.loaded_ruby_provider = 0
|
||||
vim.g.loaded_perl_provider = 0
|
||||
vim.g.loaded_node_provider = 0
|
||||
|
||||
-- Disable some in built plugins completely
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
vim.g.loaded_matchparen = 1
|
||||
vim.g.loaded_matchit = 1
|
||||
vim.g.loaded_2html_plugin = 1
|
||||
vim.g.loaded_getscriptPlugin = 1
|
||||
vim.g.loaded_gzip = 1
|
||||
vim.g.loaded_logipat = 1
|
||||
vim.g.loaded_rrhelper = 1
|
||||
vim.g.loaded_spellfile_plugin = 1
|
||||
vim.g.loaded_tarPlugin = 1
|
||||
vim.g.loaded_vimballPlugin = 1
|
||||
vim.g.loaded_zipPlugin = 1
|
||||
|
||||
-- Needs to be set before loading quickr-cscope
|
||||
vim.g.quickr_cscope_keymaps = 0
|
||||
-- Needs to be set before vimtex gets loaded, else it complains
|
||||
vim.g.tex_flavor = 'latex'
|
||||
-- Needs to be before togglelist gets loadded
|
||||
vim.g.toggle_list_no_mappings = 1
|
||||
-- Needs to be set before vim-sneak is loaded
|
||||
vim.api.nvim_command('let g:sneak#label = 1')
|
||||
vim.api.nvim_command('let g:sneak#s_next = 1')
|
||||
vim.api.nvim_command('let g:sneak#use_ic_scs = 0')
|
||||
|
||||
-- Settings using nvim.api
|
||||
-- We do this to prevent the loading of the system fzf.vim plugin. This is
|
||||
-- present at least on Arch/Manjaro
|
||||
vim.api.nvim_command('set rtp-=/usr/share/vim/vimfiles')
|
||||
vim.api.nvim_command('set shada="NONE"')
|
||||
vim.api.nvim_command('set mouse-=a')
|
||||
vim.api.nvim_command('set formatoptions+=o')
|
||||
vim.api.nvim_command('set formatoptions+=j')
|
||||
vim.api.nvim_command('set completeopt=menuone,noinsert,noselect')
|
||||
vim.api.nvim_command('set wildmenu')
|
||||
vim.api.nvim_command('set wildmode=longest:full,full')
|
||||
vim.api.nvim_command('set wildoptions=pum')
|
||||
vim.api.nvim_command('set pumblend=30')
|
||||
vim.api.nvim_command('set sessionoptions-=blank')
|
||||
vim.api.nvim_command('set backspace=indent,eol,start')
|
||||
vim.api.nvim_command('set diffopt=filler,internal,algorithm:histogram,indent-heuristic')
|
||||
|
||||
-- Add the in built Cfilter plugin. Replaces QFGrep.
|
||||
vim.cmd [[packadd cfilter]]
|
||||
|
||||
vim.cmd [[colorscheme yolokai]]
|
||||
|
||||
-- Add other lua configs or plugins
|
||||
require 'autocmd'
|
||||
require 'keymappings'
|
||||
require 'lsp'
|
||||
require 'treesitter'
|
113
nvim/.config/nvim/lua/keymappings.lua
Normal file
113
nvim/.config/nvim/lua/keymappings.lua
Normal file
|
@ -0,0 +1,113 @@
|
|||
local remap = vim.api.nvim_set_keymap
|
||||
|
||||
-- Remap escape keys to something usable on home row
|
||||
remap('i', 'jk', '<Esc>', { noremap = true })
|
||||
remap('c', 'jk', '<C-C>', { noremap = true })
|
||||
remap('i', '<Esc>', '<Nop>', { noremap = true })
|
||||
remap('c', '<Esc>', '<Nop>', { noremap = true })
|
||||
-- Use Q to execute default register.
|
||||
remap('n', 'Q', '<Nop>', { noremap = true })
|
||||
-- Save
|
||||
remap('n', '<Leader>w', '<Esc>:w<CR>', { noremap = true })
|
||||
-- Search and Replace
|
||||
remap('n', 'c.', ':%s//g<Left><Left><CR>', { noremap = true })
|
||||
remap('n', '<Leader>c.', ':%s/\\<<C-r><C-w>\\>//g<Left><Left>', { noremap = true })
|
||||
-- Quit
|
||||
remap('n', '<Leader>x', '<Esc>:x<CR>', { noremap = true })
|
||||
remap('n', '<Leader>q', '<Esc>:q<CR>', { noremap = true })
|
||||
remap('n', '<Leader>Q', '<Esc>:qa<CR>', { noremap = true })
|
||||
-- Navigate buffers
|
||||
remap('n', '[b', ':bprevious<CR>', { noremap = true })
|
||||
remap('n', ']b', ':bnext<CR>', { noremap = true })
|
||||
remap('n', '[B', ':bfirst<CR>', { noremap = true })
|
||||
remap('n', ']B', ':blast<CR>', { noremap = true })
|
||||
-- Reload buffer
|
||||
remap('n', '<Leader>e', ':e<CR>', { noremap = true })
|
||||
remap('n', '<Leader>E', ':bufdo<CR>', { noremap = true })
|
||||
-- Tab navigation
|
||||
remap('n', '<Leader>tp', ':tabprevious<CR>', { noremap = true })
|
||||
remap('n', '<Leader>tn', ':tabnext<CR>', { noremap = true })
|
||||
remap('n', '<Leader>tf', ':tabfirst<CR>', { noremap = true })
|
||||
remap('n', '<Leader>tl', ':tablast<CR>', { noremap = true })
|
||||
remap('n', '<Leader>tN', ':tabnew<CR>', { noremap = true })
|
||||
remap('n', '<Leader>tc', ':tabclose<CR>', { noremap = true })
|
||||
-- For tags
|
||||
remap('n', '[t', ':tprevious<CR>', { noremap = true })
|
||||
remap('n', ']t', ':tNext<CR>', { noremap = true })
|
||||
remap('n', '[T', ':tfirst<CR>', { noremap = true })
|
||||
remap('n', ']T', ':tlast<CR>', { noremap = true })
|
||||
remap('n', '<Leader>ts', ':exec(\"tselect \".expand(\"<cword>\"))', { noremap = true })
|
||||
-- Quickfix list mappings
|
||||
remap('n', 'qo', ':copen<CR>', { noremap = true })
|
||||
remap('n', 'qc', ':cclose<CR>', { noremap = true })
|
||||
remap('n', '[q', ':cprevious<CR>', { noremap = true })
|
||||
remap('n', ']q', ':cnext<CR>', { noremap = true })
|
||||
remap('n', '[Q', ':cfirst<CR>', { noremap = true })
|
||||
remap('n', ']Q', ':clast<CR>', { noremap = true })
|
||||
-- Location list mappings
|
||||
remap('n', 'Lo', ':lopen<CR>', { noremap = true })
|
||||
remap('n', 'Lc', ':lclose<CR>', { noremap = true })
|
||||
remap('n', '[l', ':lprevious<CR>', { noremap = true })
|
||||
remap('n', ']l', ':lnext<CR>', { noremap = true })
|
||||
remap('n', '[L', ':lfirst<CR>', { noremap = true })
|
||||
remap('n', ']L', ':lfirst<CR>', { noremap = true })
|
||||
-- Preview tags
|
||||
remap('n', 'pt', ':ptag <C-R><C-W><CR>', { noremap = true })
|
||||
remap('n', '[p', ':ptprevious<CR>', { noremap = true })
|
||||
remap('n', ']p', ':ptnext<CR>', { noremap = true })
|
||||
remap('n', 'po', ':ppop<CR>', { noremap = true })
|
||||
remap('n', 'pc', ':pc<CR>', { noremap = true })
|
||||
remap('n', 'pi', ':psearch <C-R><C-W><CR>', { noremap = true })
|
||||
-- Short cuts for setting fold methods
|
||||
remap('n', 'zmi', ':set foldmethod=indent<CR>', { noremap = true })
|
||||
remap('n', 'zmm', ':set foldmethod=manual<CR>', { noremap = true })
|
||||
remap('n', 'zme', ':set foldmethod=expr<CR>', { noremap = true })
|
||||
remap('n', 'zmk', ':set foldmethod=marker<CR>', { noremap = true })
|
||||
remap('n', 'zms', ':set foldmethod=syntax<CR>', { noremap = true })
|
||||
|
||||
-- Key Bindings to help with terminal mode
|
||||
remap('t', 'jk', '<C-\\><C-n>', { noremap = true })
|
||||
|
||||
-- Key bindings to move between window splits
|
||||
remap('n', '<Space>0', '0<C-w>w', { noremap = true })
|
||||
remap('n', '<Space>1', '1<C-w>w', { noremap = true })
|
||||
remap('n', '<Space>2', '2<C-w>w', { noremap = true })
|
||||
remap('n', '<Space>3', '3<C-w>w', { noremap = true })
|
||||
remap('n', '<Space>4', '4<C-w>w', { noremap = true })
|
||||
remap('n', '<Space>5', '5<C-w>w', { noremap = true })
|
||||
remap('n', '<Space>6', '6<C-w>w', { noremap = true })
|
||||
remap('n', '<Space>7', '7<C-w>w', { noremap = true })
|
||||
remap('n', '<Space>8', '8<C-w>w', { noremap = true })
|
||||
remap('n', '<Space>9', '9<C-w>w', { noremap = true })
|
||||
|
||||
-- Disable Arrow Keys
|
||||
remap('i', '<Up>', '<NOP>', { noremap = true })
|
||||
remap('i', '<Down>', '<NOP>', { noremap = true })
|
||||
remap('i', '<Left>', '<NOP>', { noremap = true })
|
||||
remap('i', '<Right>', '<NOP>', { noremap = true })
|
||||
remap('n', '<Up>', '<NOP>', { noremap = true })
|
||||
remap('n', '<Down>', '<NOP>', { noremap = true })
|
||||
remap('n', '<Left>', '<NOP>', { noremap = true })
|
||||
remap('n', '<Right>', '<NOP>', { noremap = true })
|
||||
|
||||
-- Tag helpers
|
||||
remap('n', '<C-\\>', ':vsp <CR>:exec(\"tag \".expand(\"<cword>\"))<CR>', { noremap = true })
|
||||
remap('n', '<A-]>', ':sp <CR>:exec(\"tag \".expand(\"<cword>\"))<CR>', { noremap = true })
|
||||
|
||||
remap('n', '<Leader>n', ':nohlsearch<CR>', { noremap = true, silent = true })
|
||||
|
||||
-- Move across wrapped lines like regular lines
|
||||
-- Go to the first non-blank character of a line
|
||||
remap('n', '0', '^', { noremap = true })
|
||||
-- Just in case you need to go to the very beginning of a line
|
||||
remap('n', '^', '0', { noremap = true })
|
||||
-- Centre the window on each search movement
|
||||
remap('n', 'n', 'nzz', { noremap = true })
|
||||
remap('n', 'N', 'Nzz', { noremap = true })
|
||||
remap('v', 'n', 'nzz', { noremap = true })
|
||||
remap('v', 'N', 'Nzz', { noremap = true })
|
||||
|
||||
-- Make dot work on visually selected lines
|
||||
remap('v', '.', ':norm.<CR>', { noremap = true })
|
||||
-- Go to the last file we changed
|
||||
remap('n', '<BS>', '<C-^>', { noremap = true })
|
|
@ -1,60 +0,0 @@
|
|||
" Better whitespace
|
||||
let g:better_whitespace_enabled = 1
|
||||
let g:strip_whitespace_on_save = 1
|
||||
let g:better_whitespace_operator = ''
|
||||
let g:strip_whitespace_confirm = 0
|
||||
" Automatically detect style file and apply style to formatting
|
||||
let g:clang_format#detect_style_file = 1
|
||||
" For workspace
|
||||
let g:workspace_session_directory = $HOME . '/.vim/session/'
|
||||
let g:workspace_undodir = $HOME . '/.vim/undodir'
|
||||
let g:workspace_autosave = 0
|
||||
let g:workspace_autosave_ignore = ['gitcommit', 'qf', 'tagbar']
|
||||
let g:workspace_session_disable_on_args = 1
|
||||
" Toggle quickfix/location list
|
||||
let g:toggle_list_no_mappings = 1
|
||||
|
||||
let g:mapleader = "\<Space>"
|
||||
let g:maplocalleader = ','
|
||||
let g:which_key_use_floating_win = 1
|
||||
|
||||
" Rainbow Parentheses
|
||||
let g:rainbow_active = 1
|
||||
|
||||
" FZF
|
||||
let $FZF_DEFAULT_OPTS="--layout=reverse --bind \"Ctrl-n:preview-down,Ctrl-p:preview-up\""
|
||||
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 } }
|
||||
|
||||
" Incremental search
|
||||
let g:incsearch#auto_nohlsearch = 1
|
||||
|
||||
" Sneak
|
||||
let g:sneak#label = 1
|
||||
let g:sneak#s_next = 1
|
||||
let g:sneak#use_ic_scs = 0
|
||||
|
||||
" vimtex
|
||||
let g:tex_flavor = 'latex'
|
||||
let g:vimtex_view_general_viewer = 'qpdfview'
|
||||
let g:vimtex_view_general_options = '--unique @pdf\#src:@tex:@line:@col'
|
||||
let g:vimtex_view_general_options_latexmk = '--unique'
|
||||
|
||||
" Floaterm
|
||||
let g:floaterm_open_in_root = 0
|
||||
let g:floaterm_position = 'center'
|
||||
let g:floaterm_width = 0.8
|
||||
let g:floaterm_height = 0.8
|
||||
let g:floaterm_winblend = 0
|
||||
let g:floaterm_borderchars = ['─', '│', '─', '│', '╭', '╮', '╯', '╰']
|
||||
|
||||
" Quickr Cscope
|
||||
let g:quickr_cscope_keymaps = 0
|
||||
|
||||
" Neovim LSP Diagnostics
|
||||
let g:diagnostic_enable_virtual_text = 0
|
||||
let g:diagnostic_show_sign = 1
|
||||
let g:diagnostic_auto_popup_while_jump = 1
|
||||
let g:diagnostic_insert_delay = 1
|
||||
|
||||
lua require 'lsp'
|
||||
lua require 'treesitter'
|
Loading…
Reference in a new issue