nvim: Except for gina migrate everything in after/plugin to lua

This commit is contained in:
Sanchayan Maity 2020-10-23 19:54:13 +05:30
parent a382ca376a
commit efc8bf88b5
29 changed files with 187 additions and 155 deletions

View file

@ -1,7 +0,0 @@
" Async Make mappings
nnoremap <LocalLeader>b :Make<CR>
nnoremap <LocalLeader>B :LMake<CR>
" Asynchronous make
command! -bang -nargs=* -complete=file Make call asyncdo#run(<bang>0, &makeprg, <f-args>)
command! -bang -nargs=* -complete=file LMake call asyncdo#lrun(<bang>0, &makeprg, <f-args>)

View file

@ -1,4 +0,0 @@
let g:better_whitespace_enabled = 1
let g:strip_whitespace_on_save = 1
let g:better_whitespace_operator = ''
let g:strip_whitespace_confirm = 0

View file

@ -1,49 +0,0 @@
let g:completion_enable_auto_popup = 0
let g:completion_auto_change_source = 1
let g:completion_trigger_on_delete = 1
let g:completion_matching_ignore_case = 0
let g:completion_matching_strategy_list = ['exact', 'substring']
let g:completion_chain_complete_list = {
\ 'c': [
\ {'complete_items': ['buffers']},
\ {'mode': 'tags'},
\ {'mode': 'keyn'},
\ {'mode': '<c-p>'},
\ {'mode': '<c-n>'}
\],
\ 'haskell': [
\ {'complete_items': ['lsp']},
\ {'complete_items': ['buffers']},
\ {'mode': 'keyn'},
\ {'mode': '<c-p>'},
\ {'mode': '<c-n>'},
\],
\ 'rust': [
\ {'complete_items': ['lsp']},
\ {'complete_items': ['buffers']},
\ {'mode': 'keyn'}
\],
\ 'purescript': [
\ {'complete_items': ['lsp']},
\ {'complete_items': ['buffers']},
\ {'mode': 'keyn'},
\ {'mode': '<c-p>'},
\ {'mode': '<c-n>'}
\],
\ 'default': [
\ {'complete_items': ['buffers']},
\ {'mode': 'keyn'},
\ {'mode': '<c-p>'},
\ {'mode': '<c-n>'},
\],
\}
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
imap <Tab> <Plug>(completion_smart_tab)
imap <C-j> <Plug>(completion_next_source)
imap <C-k> <Plug>(completion_prev_source)
" Use completion-nvim in every buffer
autocmd BufEnter * lua require'completion'.on_attach()

View file

@ -1,4 +0,0 @@
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

View file

@ -1,9 +0,0 @@
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>

View file

@ -1,9 +0,0 @@
nnoremap <Leader>fg :FZFGGrep<CR>
nnoremap <Leader>fG :FZFGrep<CR>
nnoremap <Leader>fl :FZFBLines<CR>
nnoremap <Leader>f\ :FZFRg<CR>
nnoremap <Leader>fS :exe ':FZFRg ' . expand('<cword>')<CR>
nnoremap <Leader>ft :exe ':FZFTags ' . expand('<cword>')<CR>
nnoremap <Leader>fT :FZFTags<SPACE>
nnoremap <Leader>fq :cclose<CR>:FZFQuickFix<CR>
nnoremap <Leader>fQ :lclose<CR>:FZFLocList<CR>

View file

@ -1,23 +0,0 @@
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>
nnoremap <Leader>ff :GFiles<CR>
nnoremap <Leader>fF :Files<CR>
nnoremap <Leader>fL :Lines<CR>
nnoremap <Leader>fc :BCommits<CR>
nnoremap <Leader>fC :Commits<CR>
nnoremap <Leader>fh :History:<CR>
nnoremap <Leader>fH :History/<CR>
nnoremap <Leader>fm :Commands<CR>
nnoremap <Leader>fo :Locate<SPACE>
nnoremap <Leader>fk :Maps<CR>
nnoremap <Leader>f/ :Rg<CR>
nnoremap <Leader>fs :exe ':Rg ' . expand('<cword>')<CR>
imap <C-x><C-w> <Plug>(fzf-complete-word)
imap <C-x><C-p> <Plug>(fzf-complete-path)
imap <C-x><C-f> <Plug>(fzf-complete-file)
imap <C-x><C-l> <Plug>(fzf-complete-line)

View file

@ -1 +0,0 @@
let g:rainbow_active = 1

View file

@ -1,10 +0,0 @@
nnoremap ghu :SignifyHunkUndo<CR>
nnoremap ghp :SignifyHunkDiff<CR>
nmap ]c <Plug>(signify-next-hunk)
nmap [c <Plug>(signify-prev-hunk)
nmap ]C 9999]c
nmap [C 9999[c
omap ih <Plug>(signify-motion-inner-pending)
xmap ih <Plug>(signify-motion-inner-visual)
omap ah <Plug>(signify-motion-outer-pending)
xmap ah <Plug>(signify-motion-outer-visual)

View file

@ -1,2 +0,0 @@
nnoremap qt :call ToggleQuickfixList()<CR>
nnoremap Lt :call ToggleLocationList()<CR>

View file

@ -1,17 +0,0 @@
" Replace 'f' with 1 character sneak
nmap f <Plug>Sneak_f
nmap F <Plug>Sneak_F
xmap f <Plug>Sneak_f
xmap F <Plug>Sneak_F
omap f <Plug>Sneak_f
omap F <Plug>Sneak_F
" Replace 't' with 1 character sneak
nmap t <Plug>Sneak_t
nmap T <Plug>Sneak_T
xmap t <Plug>Sneak_t
xmap T <Plug>Sneak_T
omap t <Plug>Sneak_t
omap T <Plug>Sneak_T
" Two character sneak
nmap s <Plug>Sneak_s
nmap S <Plug>Sneak_S

View file

@ -1,3 +0,0 @@
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'

View file

@ -1,4 +0,0 @@
let g:which_key_use_floating_win = 1
nnoremap <silent> <Leader> :<C-U>WhichKey '<Space>'<CR>
nnoremap <silent> <LocalLeader> :<C-U>WhichKey ','<CR>

View file

@ -1,7 +0,0 @@
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>

View file

@ -1,10 +1,9 @@
" Set up leader keys. FIXME: Move this to lua
" Set up leader
let mapleader="\<SPACE>"
let maplocalleader=","
" Use Tab & S-Tab instead of C-g and C-t for incsearch. FIXME: Move this to lua
cno <expr> <Tab> getcmdtype() =~ '[?/]' ? '<C-g>' : feedkeys('<Tab>', 'int')[1]
cno <expr> <S-Tab> getcmdtype() =~ '[?/]' ? '<C-t>' : feedkeys('<S-Tab>', 'int')[1]
" Initialise
lua require 'init'
" This seems to be required here else our colorscheme does not load
" This seems to be required here as well as in init.lua else the colorscheme
" does not take effect or load
colorscheme yolokai

View file

@ -62,8 +62,13 @@ vim.g.loaded_zipPlugin = 1
vim.g.quickr_cscope_keymaps = 0
-- Needs to be set before vimtex gets loaded, else it complains
vim.g.tex_flavor = 'latex'
vim.g.vimtex_view_general_viewer = 'qpdfview'
vim.g.vimtex_view_general_options = '--unique \\@pdf\\#src:@tex:@line:@col'
vim.g.vimtex_view_general_options_latexmk = '--unique'
-- Needs to be before togglelist gets loadded
vim.g.toggle_list_no_mappings = 1
-- Enable rainbow brackets everywhere
vim.g.rainbow_active = 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')
@ -97,3 +102,16 @@ require 'keymappings'
require 'plugins'
require 'lsp'
require 'treesitter'
-- Load plugin specific settings
require 'modules.asyncdo'
require 'modules.better-whitespace'
require 'modules.completion'
require 'modules.diagnostic'
require 'modules.floaterm'
require 'modules.fzf'
require 'modules.fzf-preview'
require 'modules.signify'
require 'modules.sneak'
require 'modules.togglelist'
require 'modules.which_key'
require 'modules.workspace'

View file

@ -111,3 +111,7 @@ remap('v', 'N', 'Nzz', { noremap = true })
remap('v', '.', ':norm.<CR>', { noremap = true })
-- Go to the last file we changed
remap('n', '<BS>', '<C-^>', { noremap = true })
-- Use Tab & S-Tab instead of C-g and C-t for incsearch
remap('c', '<Tab>', 'getcmdtype() =~ \'[?/]\' ? \'<C-g>\' : feedkeys(\'<Tab>\', \'int\')[1]', { noremap = true, expr = true })
remap('c', '<S-Tab>', 'getcmdtype() =~ \'[?/]\' ? \'<C-t>\' : feedkeys(\'<S-Tab>\', \'int\')[1]', { noremap = true, expr = true })

View file

@ -0,0 +1,7 @@
local remap = vim.api.nvim_set_keymap
remap('n', '<LocalLeader>b', ':Make<CR>', { noremap = true })
remap('n', '<LocalLeader>B', ':LMake<CR>', { noremap = true })
vim.api.nvim_command('command! -bang -nargs=* -complete=file Make call asyncdo#run(<bang>0, &makeprg, <f-args>)')
vim.api.nvim_command('command! -bang -nargs=* -complete=file LMake call asyncdo#lrun(<bang>0, &makeprg, <f-args>)')

View file

@ -0,0 +1,4 @@
vim.g.better_whitespace_enabled = 1
vim.g.strip_whitespace_on_save = 1
vim.g.better_whitespace_operator = ''
vim.g.strip_whitespace_confirm = 0

View file

@ -0,0 +1,43 @@
local remap = vim.api.nvim_set_keymap
vim.g.completion_enable_auto_popup = 0
vim.g.completion_auto_change_source = 1
vim.g.completion_trigger_on_delete = 1
vim.g.completion_matching_ignore_case = 0
vim.g.completion_matching_strategy_list = { 'exact', 'substring' }
vim.g.completion_chain_complete_list = {
c = {
{ complete_items = { 'buffers' } },
{ mode = { 'tags' } },
{ mode = { 'keyn' } },
{ mode = { '<c-p>' } },
{ mode = { '<c-n>' } }
},
haskell = {
{ complete_items = { 'buffers', 'lsp' } },
{ mode = { 'keyn' } },
{ mode = { '<c-p>' } },
{ mode = { '<c-n>' } }
},
rust = {
{ complete_items = { 'buffers', 'lsp' } },
{ mode = { 'keyn' } },
{ mode = { '<c-p>' } },
{ mode = { '<c-n>' } }
},
default = {
{ complete_items = { 'buffers' } },
{ mode = { 'keyn' } },
{ mode = { '<c-p>' } },
{ mode = { '<c-n>' } }
},
}
remap('i', '<Tab>', 'pumvisible() ? "<C-n>" : "<Tab>"', { noremap = true, expr = true })
remap('i', '<S-Tab>', 'pumvisible() ? "<C-p>" : "<S-Tab>"', { noremap = true, expr = true })
remap('i', '<Tab>', '<Plug>(completion_smart_tab)', { noremap = false })
remap('i', '<C-j>', '<Plug>(completion_next_source)', { noremap = false })
remap('i', '<C-k>', '<Plug>(completion_prev_source)', { noremap = false })
vim.api.nvim_command('autocmd BufEnter * lua require\'completion\'.on_attach()')

View file

@ -0,0 +1,4 @@
vim.g.diagnostic_enable_virtual_text = 0
vim.g.diagnostic_show_sign = 1
vim.g.diagnostic_auto_popup_while_jump = 1
vim.g.diagnostic_insert_delay = 1

View file

@ -0,0 +1,11 @@
local remap = vim.api.nvim_set_keymap
vim.g.floaterm_open_in_root = 0
vim.g.floaterm_position = 'center'
vim.g.floaterm_width = 0.8
vim.g.floaterm_height = 0.8
vim.g.floaterm_winblend = 0
vim.g.floaterm_borderchars = {'', '', '', '', '', '', '', ''}
remap('n', '<C-z>', ':FloatermToggle<Enter>', { noremap = true, silent = true })
remap('t', '<C-z>', '<C-\\><C-n>:FloatermToggle<Enter>', { noremap = true, silent = true })

View file

@ -0,0 +1,11 @@
local remap = vim.api.nvim_set_keymap
remap('n', '<Leader>fg', ':FZFGGrep<CR>', { noremap = true })
remap('n', '<Leader>fG', ':FZFGrep<CR>', { noremap = true })
remap('n', '<Leader>fl', ':FZFBLines<CR>', { noremap = true })
remap('n', '<Leader>f\\', ':FZFRg<CR>', { noremap = true })
remap('n', '<Leader>fT', ':FZFTags<SPACE>', { noremap = true })
remap('n', '<Leader>fq', ':cclose<CR>:FZFQuickFix<CR>', { noremap = true })
remap('n', '<Leader>fQ', ':lclose<CR>:FZFLocList<CR>', { noremap = true })
remap('n', '<Leader>fS', ':exe \':FZFRg \' . expand(\'<cword>\')<CR>', { noremap = true })
remap('n', '<Leader>ft', ':exe \':FZFTags \' . expand(\'<cword>\')<CR>', { noremap = true })

View file

@ -0,0 +1,30 @@
local remap = vim.api.nvim_set_keymap
vim.env.FZF_DEFAULT_OPTS = "--layout=reverse --bind \"Ctrl-n:preview-down,Ctrl-p:preview-up\""
vim.g.fzf_layout = {
window = {
width = 0.8,
height = 0.8
},
}
remap('n', '<Leader>b', ':Buffers<CR>', { noremap = true })
remap('n', '<Leader>B', ':History<CR>', { noremap = true })
remap('n', '<Leader>/', ':GFiles?<CR>', { noremap = true })
remap('n', '<Leader>ff', ':GFiles<CR>', { noremap = true })
remap('n', '<Leader>fF', ':Files<CR>', { noremap = true })
remap('n', '<Leader>fL', ':Lines<CR>', { noremap = true })
remap('n', '<Leader>fc', ':BCommits<CR>', { noremap = true })
remap('n', '<Leader>fC', ':Commits<CR>', { noremap = true })
remap('n', '<Leader>fh', ':History:<CR>', { noremap = true })
remap('n', '<Leader>fH', ':History/<CR>', { noremap = true })
remap('n', '<Leader>fm', ':Commands<CR>', { noremap = true })
remap('n', '<Leader>fo', ':Locate<CR>', { noremap = true })
remap('n', '<Leader>fk', ':Maps<CR>', { noremap = true })
remap('n', '<Leader>f/', ':Rg<CR>', { noremap = true })
remap('n', '<Leader>fs', ':exe \':Rg \' . expand(\'<cword>\')<CR>', { noremap = true })
remap('i', '<C-x><C-w>', '<Plug>(fzf-complete-word)', { noremap = false })
remap('i', '<C-x><C-p>', '<Plug>(fzf-complete-path)', { noremap = false })
remap('i', '<C-x><C-f>', '<Plug>(fzf-complete-file)', { noremap = false })
remap('i', '<C-x><C-l>', '<Plug>(fzf-complete-line)', { noremap = false })

View file

@ -0,0 +1,12 @@
local remap = vim.api.nvim_set_keymap
remap('n', 'ghu', ':SignifyHunkUndo<CR>', { noremap = true })
remap('n', 'ghp', ':SignifyHunkDiff<CR>', { noremap = true })
remap('n', ']c', '<Plug>(signify-next-hunk)', { noremap = false })
remap('n', '[c', '<Plug>(signify-prev-hunk)', { noremap = false })
remap('n', ']C', '9999]c', { noremap = false })
remap('n', '[C', '9999[c', { noremap = false })
remap('o', 'ih', '<Plug>(signify-motion-inner-pending)', { noremap = false })
remap('x', 'ih', '<Plug>(signify-motion-inner-visual)', { noremap = false })
remap('o', 'ah', '<Plug>(signify-motion-outer-pending)', { noremap = false })
remap('x', 'ah', '<Plug>(signify-motion-outer-visual)', { noremap = false })

View file

@ -0,0 +1,19 @@
local remap = vim.api.nvim_set_keymap
-- Replace 'f' with 1 character sneak
remap('n', 'f', '<Plug>Sneak_f', { noremap = false })
remap('n', 'F', '<Plug>Sneak_F', { noremap = false })
remap('x', 'f', '<Plug>Sneak_f', { noremap = false })
remap('x', 'F', '<Plug>Sneak_F', { noremap = false })
remap('o', 'f', '<Plug>Sneak_f', { noremap = false })
remap('o', 'F', '<Plug>Sneak_F', { noremap = false })
-- Replace 't' with 1 character sneak
remap('n', 't', '<Plug>Sneak_t', { noremap = false })
remap('n', 'T', '<Plug>Sneak_T', { noremap = false })
remap('x', 't', '<Plug>Sneak_t', { noremap = false })
remap('x', 'T', '<Plug>Sneak_T', { noremap = false })
remap('o', 't', '<Plug>Sneak_t', { noremap = false })
remap('o', 'T', '<Plug>Sneak_T', { noremap = false })
-- Two character sneak
remap('n', 's', '<Plug>Sneak_s', { noremap = false })
remap('n', 'S', '<Plug>Sneak_S', { noremap = false })

View file

@ -0,0 +1,4 @@
local remap = vim.api.nvim_set_keymap
remap('n', 'qt', ':call ToggleQuickfixList()<CR>', { noremap = true })
remap('n', 'Lt', ':call ToggleLocationList()<CR>', { noremap = true })

View file

@ -0,0 +1,6 @@
local remap = vim.api.nvim_set_keymap
vim.g.which_key_use_floating_win = 1
remap('n', '<Leader>', ':<C-U>WhichKey \'<Space>\'<CR>', { noremap = true, silent = true })
remap('n', '<LocalLeader>', ':<C-U>WhichKey \',\'<CR>', { noremap = true, silent = true })

View file

@ -0,0 +1,9 @@
local remap = vim.api.nvim_set_keymap
vim.g.workspace_session_directory = vim.fn.expand('~/.vim/session/')
vim.g.workspace_undodir = vim.fn.expand('~/.vim/undodir')
vim.g.workspace_autosave = 0
vim.g.workspace_autosave_ignore = {'gitcommit', 'qf', 'tagbar'}
vim.g.workspace_session_disable_on_args = 1
remap('n', '<Leader>ps', ':ToggleWorkspace<CR>', { noremap = true })