neovim: revamp

- packer: load vim-eft, nvim-spectre, nvim-dap, persistence.nvim on key
  press instead of on Vim event
- keybindings: redefine multiple, move keybindings for plugins loaded on
  key press to their configs
- plugins: add winshift.nvim, better-escape.nvim, window-picker.nvim,
  neogen, spellsitter.nvim, nvim-lightbulb, close-buffers.nvim
- init.lua: move autocmds back inside async loop (filetype events already
  got handled by filetype.nvim)
- zen-mode.nvim + twilight.nvim: move from 'tools' to 'editor' group
- lsp: change signs characters for unification
- dap: initial config, keybindings
- feline.nvim: reorder elements, add nvim-lightbulb signs
- chore: unify the way setup() is called, and format stuff
This commit is contained in:
FollieHiyuki 2021-10-12 02:33:22 +07:00
parent a2a7caa279
commit 61b5cb5b70
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
11 changed files with 502 additions and 208 deletions

View File

@ -1,5 +1,6 @@
local async
async = vim.loop.new_async(vim.schedule_wrap(function()
require('autocmd')
require('plugins')
require('mappings')
async:close()
@ -10,5 +11,4 @@ local options = require('options')
options.disable_default_plugins()
options.load_options()
require('colors.' .. vim.g.global_theme).highlight()
require('autocmd')
async:send()

View File

@ -1,20 +1,16 @@
local definitions = {
-- ':h hex-editing'
-- binary = {
-- {'BufReadPre' , '*.bin,*.exe', 'let &bin=1'},
-- {'BufReadPost' , '*.bin,*.exe', 'if &bin | %!xxd'},
-- {'BufReadPost' , '*.bin,*.exe', 'set ft=xxd | endif'},
-- {'BufWritePre' , '*.bin,*.exe', 'if &bin | %!xxd -r'},
-- {'BufWritePre' , '*.bin,*.exe', 'endif'},
-- {'BufWritePost', '*.bin,*.exe', 'if &bin | %!xxd'},
-- {'BufWritePost', '*.bin,*.exe', 'set nomod | endif'}
-- },
-- Auto-hide UI elements in specific buffers
-- buf = {
-- {'BufEnter', 'term://*', 'setlocal norelativenumber nonumber'},
-- {'BufEnter,BufWinEnter,WinEnter,CmdwinEnter', '*', [[if bufname('%') == 'NvimTree' | set laststatus=0 | else | set laststatus=2 | endif]]}
-- },
bufs = {
-- Reload vim config automatically
{'BufWritePost', [[$VIM_PATH/{*.vim,*.yaml,vimrc} nested source $MYVIMRC | redraw]]},
-- Reload Vim script automatically if setlocal autoread
{'BufWritePost,FileWritePost', '*.vim', [[nested if &l:autoread > 0 | source <afile> | echo 'source ' . bufname('%') | endif]]},
-- No undo for temporary files
{'BufWritePre', '/tmp/*', 'setlocal noundofile'},
{'BufWritePre', 'COMMIT_EDITMSG', 'setlocal noundofile'},
{'BufWritePre', 'MERGE_MSG', 'setlocal noundofile'},
{'BufWritePre', '*.tmp', 'setlocal noundofile'},
{'BufWritePre', '*.bak', 'setlocal noundofile'}
},
wins = {
-- Equalize window dimensions when resizing vim window
@ -22,7 +18,7 @@ local definitions = {
-- Force writing shada on leaving nvim
{'VimLeave', '*', [[if has('nvim') | wshada! | else | wviminfo! | endif]]},
-- Check if file changed when its window is focus, more eager than 'autoread'
-- {'FocusGained', '* checktime'}
{'FocusGained', '* checktime'}
},
yank = {

View File

@ -280,27 +280,27 @@ local function highlight_lsp()
vim.api.nvim_command('hi! link LspCodeLens Comment')
-- Theses are for neovim 0.6
vim.api.nvim_command('hi! link DiagnosticVirtualTextWarn LspDiagnosticsVirtualTextWarning')
vim.api.nvim_command('hi! link DiagnosticUnderlineWarn LspDiagnosticsUnderlineWarning')
vim.api.nvim_command('hi! link DiagnosticFloatingWarn LspDiagnosticsFloatingWarning')
vim.api.nvim_command('hi! link DiagnosticSignWarn LspDiagnosticsSignWarning')
vim.api.nvim_command('hi! link DiagnosticVirtualTextError LspDiagnosticsVirtualTextError')
vim.api.nvim_command('hi! link DiagnosticUnderlineError LspDiagnosticsUnderlineError')
vim.api.nvim_command('hi! link DiagnosticFloatingError LspDiagnosticsFloatingError')
vim.api.nvim_command('hi! link DiagnosticSignError LspDiagnosticsSignError')
vim.api.nvim_command('hi! link DiagnosticVirtualTextInfo LspDiagnosticsVirtualTextInformation')
vim.api.nvim_command('hi! link DiagnosticUnderlineInfo LspDiagnosticsUnderlineInformation')
vim.api.nvim_command('hi! link DiagnosticFloatingInfo LspDiagnosticsFloatingInformation')
vim.api.nvim_command('hi! link DiagnosticSignInfo LspDiagnosticsSignInformation')
vim.api.nvim_command('hi! link DiagnosticVirtualTextHint LspDiagnosticsVirtualTextHint')
vim.api.nvim_command('hi! link DiagnosticUnderlineHint LspDiagnosticsUnderlineHint')
vim.api.nvim_command('hi! link DiagnosticFloatingHint LspDiagnosticsFloatingHint')
vim.api.nvim_command('hi! link DiagnosticSignHint LspDiagnosticsSignHint')
-- vim.api.nvim_command('hi! link DiagnosticVirtualTextWarn LspDiagnosticsVirtualTextWarning')
-- vim.api.nvim_command('hi! link DiagnosticUnderlineWarn LspDiagnosticsUnderlineWarning')
-- vim.api.nvim_command('hi! link DiagnosticFloatingWarn LspDiagnosticsFloatingWarning')
-- vim.api.nvim_command('hi! link DiagnosticSignWarn LspDiagnosticsSignWarning')
-- vim.api.nvim_command('hi! link DiagnosticVirtualTextError LspDiagnosticsVirtualTextError')
-- vim.api.nvim_command('hi! link DiagnosticUnderlineError LspDiagnosticsUnderlineError')
-- vim.api.nvim_command('hi! link DiagnosticFloatingError LspDiagnosticsFloatingError')
-- vim.api.nvim_command('hi! link DiagnosticSignError LspDiagnosticsSignError')
-- vim.api.nvim_command('hi! link DiagnosticVirtualTextInfo LspDiagnosticsVirtualTextInformation')
-- vim.api.nvim_command('hi! link DiagnosticUnderlineInfo LspDiagnosticsUnderlineInformation')
-- vim.api.nvim_command('hi! link DiagnosticFloatingInfo LspDiagnosticsFloatingInformation')
-- vim.api.nvim_command('hi! link DiagnosticSignInfo LspDiagnosticsSignInformation')
-- vim.api.nvim_command('hi! link DiagnosticVirtualTextHint LspDiagnosticsVirtualTextHint')
-- vim.api.nvim_command('hi! link DiagnosticUnderlineHint LspDiagnosticsUnderlineHint')
-- vim.api.nvim_command('hi! link DiagnosticFloatingHint LspDiagnosticsFloatingHint')
-- vim.api.nvim_command('hi! link DiagnosticSignHint LspDiagnosticsSignHint')
end
-- Specify groups for plugins
local function highlight_plugins()
-- nvim-cmp (experimental custom menu)
-- nvim-cmp
hi('CmpItemAbbr', c.fg, '', '', '')
hi('CmpItemAbbrMatch', c.yellow, '', '', '')
hi('CmpItemAbbrMatchFuzzy', c.yellow, '', '', '')
@ -365,8 +365,13 @@ local function highlight_plugins()
hi('IndentBlanklineChar', c.grey1, '', '', '')
hi('IndentBlanklineContextChar', c.grey1, '', '', '')
-- window-picker.nvim
hi('WindowPicker', c.fg, c.blue, 'bold', '')
hi('WindowPickerSwap', c.fg, c.orange, 'bold', '')
-- vim-illuminate
vim.api.nvim_command('hi! link illuminatedWord Underline')
vim.api.nvim_command('hi! link illuminatedCurWord Underline')
-- trouble.nvim
hi('LspTroubleText', c.blue, '', 'bold', '')

View File

@ -1,15 +1,5 @@
local M = {}
local function hi(group, guifg, guibg, attr, guisp)
local fg = guifg ~= '' and 'guifg=' .. guifg or 'guifg=NONE'
local bg = guibg ~= '' and 'guibg=' .. guibg or 'guibg=NONE'
local style = attr ~= '' and 'gui=' .. attr or 'gui=NONE'
local sp = guisp ~= '' and 'guisp=' .. guisp or ''
local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp
vim.api.nvim_command(hl)
end
M.colors = {
black = '#282C34',
grey1 = '#3E4452',
@ -34,6 +24,16 @@ M.colors = {
local c = M.colors
local function hi(group, guifg, guibg, attr, guisp)
local fg = guifg ~= '' and 'guifg=' .. guifg or 'guifg=NONE'
local bg = guibg ~= '' and 'guibg=' .. guibg or 'guibg=NONE'
local style = attr ~= '' and 'gui=' .. attr or 'gui=NONE'
local sp = guisp ~= '' and 'guisp=' .. guisp or ''
local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp
vim.api.nvim_command(hl)
end
function M.highlight()
hi('ModeMsg', c.green, '', '', '')
end

View File

@ -18,9 +18,6 @@ local function pandoc_convert(ofiletype)
vim.fn.jobstart(cmd)
end
-- No one likes Esc
api.nvim_set_keymap('i', 'jk', [[<Esc>]], {noremap = true, silent = true})
-- Escape to normal mode in terminal buffer
api.nvim_set_keymap('t', '<Esc>', '<C-\\><C-n>', {noremap = true, silent = true})
@ -28,17 +25,13 @@ api.nvim_set_keymap('t', '<Esc>', '<C-\\><C-n>', {noremap = true, silent = true}
api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true})
api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true})
-- vim-eft
api.nvim_set_keymap('n', 'f', '<Plug>(eft-f)', {})
api.nvim_set_keymap('x', 'f', '<Plug>(eft-f)', {})
api.nvim_set_keymap('n', 'F', '<Plug>(eft-F)', {})
api.nvim_set_keymap('x', 'F', '<Plug>(eft-F)', {})
api.nvim_set_keymap('n', 't', '<Plug>(eft-t)', {})
api.nvim_set_keymap('x', 't', '<Plug>(eft-t)', {})
api.nvim_set_keymap('n', 'T', '<Plug>(eft-T)', {})
api.nvim_set_keymap('x', 'T', '<Plug>(eft-T)', {})
api.nvim_set_keymap('n', ';', '<Plug>(eft-repeat)', {})
api.nvim_set_keymap('x', ';', '<Plug>(eft-repeat)', {})
-- winshift.nvim
api.nvim_set_keymap('n', '<C-w><C-m>', ':WinShift<CR>', {noremap = true, silent = true})
api.nvim_set_keymap('n', '<C-w>m', ':WinShift<CR>', {noremap = true, silent = true})
api.nvim_set_keymap('n', '<C-A-h>', ':WinShift left<CR>', {noremap = true, silent = true})
api.nvim_set_keymap('n', '<C-A-j>', ':WinShift down<CR>', {noremap = true, silent = true})
api.nvim_set_keymap('n', '<C-A-k>', ':WinShift up<CR>', {noremap = true, silent = true})
api.nvim_set_keymap('n', '<C-A-l>', ':WinShift right<CR>', {noremap = true, silent = true})
-----------------
-- Normal mode --
@ -51,18 +44,14 @@ wk.register({
H = {'^', 'Start of the line'},
L = {'$', 'End of the line'},
-- Easier moving between windows
-- ['<C-h>'] = {'<C-w>h', 'Go to the left window'},
-- ['<C-l>'] = {'<C-w>l', 'Go to the right window'},
-- ['<C-j>'] = {'<C-w>j', 'Go to the down window'},
-- ['<C-k>'] = {'<C-w>k', 'Go to the up window'},
['<C-q>'] = {'<C-w>q', 'Quit a window'},
-- Close a window
['<C-q>'] = {'<C-w>q', 'Quit current window'},
-- Copy the whole buffer
['<C-a>'] = {'<Cmd>%y+<CR>', 'Copy whole buffer'},
['<C-a>'] = {':%y+<CR>', 'Copy whole buffer'},
-- Close buffer
['<C-x>'] = {':bd!<CR>', 'Close buffer'},
['<C-x>'] = {':bdelete<CR>', 'Close current buffer'},
-- Remove trailing whitespace
['<A-w>'] = {':%s/\\s\\+$//e<CR>', 'Remove trailing'},
@ -108,14 +97,17 @@ wk.register({
D = 'Go to declaration',
i = 'Go to implementation',
r = 'Go to references',
R = {'<Cmd>TroubleToggle lsp_references<CR>', 'Reference list'}
R = {':TroubleToggle lsp_references<CR>', 'Reference list'}
},
K = {name = 'Hover'},
z = {name = 'Misc utils'},
-- Window picker
['-'] = {':WindowPick<CR>', 'Choose window'},
-- Move between tabs
['<TAB>'] = {'<Cmd>BufferLineCycleNext<CR>', 'Next buffer'},
['<S-TAB>'] = {'<Cmd>BufferLineCyclePrev<CR>', 'Previous buffer'},
['<TAB>'] = {':BufferLineCycleNext<CR>', 'Next buffer'},
['<S-TAB>'] = {':BufferLineCyclePrev<CR>', 'Previous buffer'},
-- NvimTree
['<C-n>'] = {':NvimTreeToggle<CR>', 'NvimTree'},
@ -134,25 +126,21 @@ wk.register({
-- Normal mode (with leader key) --
-----------------------------------
wk.register({
a = {
name = 'Action',
a = {':EasyAlign<CR>', 'Align elements'},
s = {':ISwapWith<CR>', 'Swap elements'}
},
b = {
name = 'Buffer/Tab',
name = 'Buffer',
c = {':ColorizerToggle<CR>', 'Colorizer'},
d = {':bdelete<CR>', 'Close buffer'},
d = {
name = 'Delete',
a = {':BDelete all<CR>', 'All buffers'},
d = {':BDelete this<CR>', 'Current buffer'},
h = {':BDelete hidden<CR>', 'Hidden buffers'},
n = {':BDelete nameless<CR>', 'Buffers without name'},
o = {':BDelete other<CR>', 'Other buffers'}
},
j = {':BufferLineCyclePrev<CR>', 'Previous buffer'},
k = {':BufferLineCycleNext<CR>', 'Next buffer'},
n = {':enew<CR>', 'New buffer'},
u = {':UndotreeToggle<CR>', 'Undotree'},
z = {':ZenMode<CR>', 'Zen mode'},
D = {'<Cmd>tabclose<CR>', 'Close tab'},
J = {'<Cmd>tabprev<CR>', 'Previous tab'},
K = {'<Cmd>tabnext<CR>', 'Next tab'},
N = {'<Cmd>tabnew<CR>', 'New tab'},
v = {
name = 'Convert',
m = {function() pandoc_convert('md') end, 'To Markdown'},
@ -166,23 +154,29 @@ wk.register({
d = {
name = 'DAP',
b = {':lua require("dap").toggle_breakpoint()<CR>', 'Toggle breakpoint'},
c = {':lua require("dapui").close()<CR>', 'Close UI'},
e = {':lua require("dapui").eval()<CR>', 'Evaluate cursorword'},
f = {':lua require("dapui").float_element()<CR>', 'Float elements'},
i = {':lua require("dap").repl.open()<CR>', 'Inspect via REPL'},
n = {':lua require("dap").step_into()<CR>', 'Step through code'},
o = {':lua require("dapui").open()<CR>', 'Open UI'},
s = {':lua require("dap").continue()<CR>', 'Debug session'},
t = {':lua require("dapui").open()<CR>', 'Toggle UI'}
b = 'Toggle breakpoint',
B = 'Set breakpoint with condition',
c = 'Run to cursor',
d = 'Disconnect adapter',
e = 'Hover under cursor (UI)',
f = 'Open float window (UI)',
i = 'Step into function/method',
l = 'List breakpoints',
n = 'Resume the execution',
o = 'Step out of function/method',
r = 'Inspect in REPL',
t = 'Toggle UI',
v = 'Run again 1 step',
z = 'Re-run the last adapter'
},
e = {
name = 'Session',
s = {':lua require("persistence").save()<CR>', 'Save session for current directory'},
d = {':lua require("persistence").stop()<CR>', 'Stop automatically saving'},
l = {':lua require("persistence").load({last = true})<CR>', 'Load last session'},
r = {':lua require("persistence").load()<CR>', 'Load session for current directory'}
name = 'Editor',
a = {':EasyAlign<CR>', 'Align elements'},
g = 'Generate annotations',
s = {':ISwapWith<CR>', 'Swap elements'},
t = {':Twilight<CR>', 'Twilight mode'},
z = {':ZenMode<CR>', 'Zen mode'}
},
-- Telescope
@ -223,6 +217,8 @@ wk.register({
S = 'Stage buffer',
u = 'Undo hunk',
U = 'Reset buffer index',
y = 'Get remote url for cursorline',
Y = 'Get remote url',
n = {':Neogit<CR>', 'Neogit'},
f = {
name = 'Telescope',
@ -279,6 +275,13 @@ wk.register({
}
},
p = {
name = 'Find/Replace',
o = 'Open spectre',
p = 'Search in current file',
w = 'Find/replace cursorword'
},
r = {
name = 'REST',
c = {'<Plug>RestNvim', 'Run request under cursor'},
@ -287,10 +290,11 @@ wk.register({
},
s = {
name = 'Find/Replace',
o = {':lua require("spectre").open()<CR>', 'Open spectre'},
p = {'viw:lua require("spectre").open_file_search()<CR>', 'Search in current file'},
w = {':lua require("spectre").open_visual({select_word = true})<CR>', 'Find/replace cursorword'},
name = 'Session',
s = 'Save session for current directory',
d = 'Stop automatically saving',
l = 'Load last session',
r = 'Load session for current directory'
},
-- t = {
@ -327,13 +331,14 @@ wk.register({
d = {
name = 'DAP',
e = {':lua require("dapui").eval()<CR>', 'Evaluate highlighted text'}
e = 'Hover on range (UI)'
},
g = {
name = 'Git',
r = 'Reset hunk',
s = 'Stage hunk'
s = 'Stage hunk',
y = 'Get remote url for range'
},
j = {
@ -344,7 +349,7 @@ wk.register({
c = {'c<C-R>=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]<S-Left><S-Left><Right>', 'Translate and replace with direction'}
},
s = {':lua require("spectre").open_visual()<CR>', 'Find/Replace'}
p = 'Find/Replace'
}, {mode = 'v', prefix = '<leader>'})
------------------------

View File

@ -62,22 +62,25 @@ function M.cmp_conf()
return vim_item
end
},
-- documentation = {
-- border = {'╭', '─', '╮', '│', '╯', '─', '╰', '│'}
-- },
mapping = {
['<C-Space>'] = cmp.mapping.complete(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-e>'] = cmp.mapping.close(),
['<C-d>'] = cmp.mapping.close(),
-- Change choice nodes for luasnip
['<C-h>'] = cmp.mapping(function(fallback)
['<C-j>'] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
luasnip.change_choice(-1)
else
fallback()
end
end, {'i', 's'}),
['<C-l>'] = cmp.mapping(function(fallback)
['<C-k>'] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
luasnip.change_choice(1)
else
@ -132,21 +135,21 @@ end
-- function M.tabnine_conf()
-- local tabnine = require('cmp_tabnine.config')
-- tabnine:setup({
-- tabnine:setup {
-- max_lines = 1000,
-- max_num_results = 20,
-- sort = true,
-- run_on_every_keystroke = true
-- })
-- }
-- end
function M.autopairs_conf()
require('nvim-autopairs').setup {fast_wrap = {}}
require('nvim-autopairs.completion.cmp').setup({
require('nvim-autopairs.completion.cmp').setup {
map_cr = true, -- map <CR> on insert mode
map_complete = true, -- it will auto insert `(` after select function or method item
auto_select = true -- automatically select the first item
})
}
end
function M.snippets_conf()
@ -189,12 +192,12 @@ end
-- end
function M.autotag_conf()
require('nvim-ts-autotag').setup({
require('nvim-ts-autotag').setup {
filetypes = {
'html', 'javascript', 'javascriptreact', 'typescript',
'typescriptreact', 'svelte', 'vue'
}
})
}
end
return M

View File

@ -16,6 +16,11 @@ function M.colorizer_conf()
})
end
function M.illuminate_conf()
vim.g.Illuminate_delay = 500
vim.g.Illuminate_ftblacklist = {'alpha', 'NvimTree', 'undotree', 'packer'}
end
function M.blankline_conf()
require('indent_blankline').setup {
char = '',
@ -99,6 +104,13 @@ function M.treesitter_conf()
}
end
-- function M.spellsitter_conf()
-- require('spellsitter').setup {
-- hl = 'SpellBad',
-- captures = {'comment'}
-- }
-- end
function M.iswap_conf()
require('iswap').setup {
-- The keys that will be used as a selection, in order
@ -141,16 +153,91 @@ function M.matchup_conf()
vim.g.matchup_matchparen_offscreen = {method = 'popup'}
end
function M.twilight_conf()
require('twilight').setup {
dimming = {
alpha = 0.25, -- amount of dimming
-- we try to get the foreground from the highlight groups or fallback color
color = {'Normal', '#ffffff'},
inactive = false -- when true, other windows will be fully dimmed (unless they contain the same buffer)
},
context = 10,
treesitter = true,
expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
'function',
'method',
'table',
'if_statement'
},
exclude = {'alpha', 'packer', 'NvimTree', 'qf'}
}
end
function M.zenmode_conf()
require('zen-mode').setup {
window = {
options = {
signcolumn = 'no',
number = false,
relativenumber = false,
cursorline = false,
cursorcolumn = false,
foldcolumn = '0'
}
},
-- on_open = function()
-- vim.api.nvim_command('TSContextDisable')
-- vim.api.nvim_command('IndentBlanklineDisable')
-- end,
-- on_close = function()
-- vim.api.nvim_command('TSContextEnable')
-- vim.api.nvim_command('IndentBlanklineEnable')
-- end
}
end
function M.betterescape_conf()
require('better_escape').setup {
mapping = {'jk', 'kj'},
timeout = vim.opt.timeoutlen:get(),
clear_empty_lines = false,
keys = '<Esc>'
}
end
function M.hop_conf()
require('hop').setup {keys = 'etovxqpdygfblzhckisuran'}
end
function M.eft_conf()
vim.g.eft_index_function = {all = function() return true end}
-- Mappings
vim.api.nvim_set_keymap('n', 'f', '<Plug>(eft-f)', {})
vim.api.nvim_set_keymap('x', 'f', '<Plug>(eft-f)', {})
vim.api.nvim_set_keymap('n', 'F', '<Plug>(eft-F)', {})
vim.api.nvim_set_keymap('x', 'F', '<Plug>(eft-F)', {})
vim.api.nvim_set_keymap('n', 't', '<Plug>(eft-t)', {})
vim.api.nvim_set_keymap('x', 't', '<Plug>(eft-t)', {})
vim.api.nvim_set_keymap('n', 'T', '<Plug>(eft-T)', {})
vim.api.nvim_set_keymap('x', 'T', '<Plug>(eft-T)', {})
vim.api.nvim_set_keymap('n', ';', '<Plug>(eft-repeat)', {})
vim.api.nvim_set_keymap('x', ';', '<Plug>(eft-repeat)', {})
end
function M.comment_conf()
require('nvim_comment').setup({comment_empty = false})
require('nvim_comment').setup {comment_empty = false}
end
function M.neogen_conf()
require('neogen').setup {
enabled = true,
input_after_comment = true,
jump_map = '<C-e>'
}
-- Mappings
vim.api.nvim_set_keymap('n', '<leader>eg', ':lua require("neogen").generate()<CR>', {noremap = true, silent = true})
end
function M.project_conf()
@ -162,6 +249,40 @@ function M.project_conf()
silent_chdir = true,
datapath = vim.fn.stdpath('data')
}
-- cd on local window changes with 'lcd' (more eager)
-- see https://github.com/ahmedkhalf/project.nvim/issues/23
-- _G.set_window_project_dir = function()
-- local root, _ = require('project_nvim.project').get_project_root()
-- if root then
-- vim.api.nvim_command('lcd ' .. root)
-- end
-- end
-- vim.api.nvim_command('autocmd BufEnter * lua set_window_project_dir()')
end
function M.gitlinker_conf()
require('gitlinker').setup {
opts = {
remote = nil, -- force the use of a specific remote
-- adds current line nr in the url for normal mode
add_current_line_on_normal_mode = true,
-- callback for what to do with the url
action_callback = require('gitlinker.actions').copy_to_clipboard,
-- print the url after performing the action
print_url = true,
},
callbacks = {
['git.folliehiyuki.com'] = require('gitlinker.hosts').get_gitea_type_url,
['git.disroot.org'] = require('gitlinker.hosts').get_gitea_type_url,
['gitlab.alpinelinux.org'] = require('gitlinker.hosts').get_gitlab_type_url
},
-- default mapping to call url generation with action_callback
mappings = '<leader>gy'
}
-- Mapping to get remote url
vim.api.nvim_set_keymap('n', '<leader>gY', ':lua require("gitlinker").get_repo_url()<CR>', {noremap = true, silent = true})
end
return M

View File

@ -284,9 +284,9 @@ function M.lsp_conf()
-- Replace the default lsp diagnostic letters with prettier symbols
vim.fn.sign_define('LspDiagnosticsSignError', {text = ''})
vim.fn.sign_define('LspDiagnosticsSignWarning', {text = ''})
vim.fn.sign_define('LspDiagnosticsSignWarning', {text = ''})
vim.fn.sign_define('LspDiagnosticsSignInformation', {text = ''})
vim.fn.sign_define('LspDiagnosticsSignHint', {text = ''})
vim.fn.sign_define('LspDiagnosticsSignHint', {text = ''})
end
function M.sqls_conf()
@ -295,6 +295,12 @@ function M.sqls_conf()
}
end
function M.lightbulb_conf()
vim.api.nvim_command [[
autocmd CursorHold,CursorHoldI * lua require('nvim-lightbulb').update_lightbulb {sign = {enabled = false}, status_text = {enabled = true, text = ' Code action', text_unavailable = ''}}
]]
end
function M.trouble_conf()
require('trouble').setup {
mode = 'lsp_workspace_diagnostics',
@ -307,9 +313,9 @@ function M.trouble_conf()
},
signs = {
error = '',
warning = '',
hint = '',
warning = '',
information = '',
hint = '',
other = ''
}
}
@ -379,13 +385,75 @@ end
function M.dap_conf()
local dap = require('dap')
vim.fn.sign_define('DapBreakpoint', {text='', texthl='Red'})
vim.fn.sign_define('DapLogPoint', {text='', texthl='Red'})
vim.fn.sign_define('DapStopped', {text='', texthl='Red'})
vim.fn.sign_define('DapBreakpointRejected', {text='', texthl='Red'})
vim.fn.sign_define('DapBreakpoint', {text='', texthl='Orange'})
vim.fn.sign_define('DapLogPoint', {text='', texthl='Orange'})
vim.fn.sign_define('DapStopped', {text='', texthl='Orange'})
vim.fn.sign_define('DapBreakpointRejected', {text='', texthl='Red'})
-- Mappings
vim.api.nvim_command('n', '<leader>dn', ':lua require("dap").continue()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>dd', ':lua require("dap").disconnect()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>db', ':lua require("dap").toggle_breakpoint()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>dB', ':lua require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>dl', ':lua require("dap").list_breakpoints()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>dc', ':lua require("dap").run_to_cursor()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>dz', ':lua require("dap").run_last()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<F9>', ':lua require("dap").step_over()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>dv', ':lua require("dap").step_over()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<F10>', ':lua require("dap").step_into()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>di', ':lua require("dap").step_into()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<F11>', ':lua require("dap").step_out()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>do', ':lua require("dap").step_out()<CR>', {noremap = true, silent = true})
vim.api.nvim_command('n', '<leader>dr', ':lua require("dap").repl.open()<CR>', {noremap = true, silent = true})
end
function M.dapui_conf()
local dap, dapui = require('dap'), require('dapui')
dap.listeners.after.event_initialized['dapui_config'] = function() dapui.open() end
dap.listeners.before.event_terminated['dapui_config'] = function() dapui.close() end
dap.listeners.before.event_exited['dapui_config'] = function() dapui.close() end
require('dapui').setup {
icons = {expanded = '', collapsed = ''},
mappings = {
expand = {'<CR>', '<2-LeftMouse>'},
open = 'o',
remove = 'd',
edit = 'e',
repl = 'r'
},
sidebar = {
elements = {
-- Provide as ID strings or tables with 'id' and 'size' keys
-- 'size' can be float or integer > 1
{id = 'scopes', size = 0.25},
{id = 'breakpoints', size = 0.25},
{id = 'stacks', size = 0.25},
{id = 'watches', size = 0.25},
},
size = 40,
position = 'left'
},
tray = {
elements = {'repl'},
size = 10,
position = 'bottom'
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
mappings = {
close = {'q', '<Esc>'}
}
},
windows = {indent = 1}
}
-- Mappings
vim.api.nvim_set_keymap('n', '<leader>de', ':lua require("dapui").eval()<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('v', '<leader>de', ':lua require("dapui").eval()<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>df', ':lua require("dapui").float_element()<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>dt', ':lua require("dapui").toggle()<CR>', {noremap = true, silent = true})
end
return M

View File

@ -34,7 +34,7 @@ function M.telescope_conf()
},
extensions = {
project = {
base_dirs = {{'~/Code', max_depth = 4}},
base_dirs = {{os.getenv('HOME') .. '/Code', max_depth = 4}},
hidden_files = true
},
fzf = {
@ -92,7 +92,7 @@ function M.markdown_preview_conf()
end
function M.rest_conf()
require('rest-nvim').setup({
require('rest-nvim').setup {
-- Open request results in a horizontal split
result_split_horizontal = false,
-- Skip SSL verification, useful for unknown certificates
@ -104,36 +104,13 @@ function M.rest_conf()
},
-- Jump to request line on run
jump_to_request = false,
})
end
function M.zenmode_conf()
require('zen-mode').setup {
window = {
options = {
signcolumn = 'no',
number = false,
relativenumber = false,
cursorline = false,
cursorcolumn = false,
foldcolumn = '0'
}
},
on_open = function()
vim.api.nvim_command('TSContextDisable')
vim.api.nvim_command('IndentBlanklineDisable')
end,
on_close = function()
vim.api.nvim_command('TSContextEnable')
-- vim.api.nvim_command('IndentBlanklineEnable')
end
}
end
function M.orgmode_conf()
local c = require('colors.' .. vim.g.global_theme).colors
require('orgmode').setup({
require('orgmode').setup {
-- General settings
org_agenda_files = {'~/Documents/Org/agenda/*'},
org_default_notes_file = '~/Documents/Org/notes.org',
@ -166,7 +143,7 @@ function M.orgmode_conf()
-- Tags settings
org_use_tag_inheritance = false
})
}
end
function M.vimtex_conf()
@ -174,6 +151,12 @@ end
function M.spectre_conf()
require('spectre').setup()
-- Mappings
vim.api.nvim_set_keymap('n', '<leader>po', ':lua require("spectre").open()<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>pp', 'viw:lua require("spectre").open_file_search()<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>pw', ':lua require("spectre").open_visual({select_word = true})<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('v', '<leader>p', ':lua require("spectre").open_visual()<CR>', {noremap = true, silent = true})
end
function M.translate_conf()
@ -302,10 +285,16 @@ function M.session_conf()
dir = vim.fn.expand(vim.fn.stdpath('data') .. '/sessions/'),
options = {'buffers', 'curdir', 'tabpages', 'winsize'}
}
-- Mappings
vim.api.nvim_set_keymap('n', '<leader>ss', ':lua require("persistence").save()<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>sd', ':lua require("persistence").stop()<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>sl', ':lua require("persistence").load({last = true})<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>sr', ':lua require("persistence").load()<CR>', {noremap = true, silent = true})
end
function M.filetype_conf()
require('filetype').setup({
require('filetype').setup {
overrides = {
extensions = {
md = 'markdown',
@ -321,10 +310,51 @@ function M.filetype_conf()
},
complex = {
['*_log'] = 'log',
['G*_LOG'] = 'log'
['G*_LOG'] = 'log',
['.*waybar/config'] = 'jsonc'
}
}
})
}
end
function M.closebuf_conf()
require('close_buffers').setup {
preserve_window_layout = {'this'},
next_buffer_cmd = function(windows)
require('bufferline').cycle(1)
local bufnr = vim.api.nvim_get_current_buf()
for _, window in ipairs(windows) do
vim.api.nvim_win_set_buf(window, bufnr)
end
end
}
end
function M.winshift_conf()
require('winshift').setup {
highlight_moving_win = true, -- Highlight the window being moved
focused_hl_group = 'Visual', -- The highlight group used for the moving window
moving_win_options = {
-- These are local options applied to the moving window while it's
-- being moved. They are unset when you leave Win-Move mode.
wrap = false,
cursorline = false,
cursorcolumn = false,
colorcolumn = '',
}
}
end
function M.winpicker_conf()
require('window-picker').setup {
keys = 'alskdjfhgwoeiruty',
-- Swap windows by holding shift + letter
swap_shift = true,
exclude = {qf = true, NvimTree = true, packer = true, alpha = true},
-- Flash the cursor line of the newly focused window
flash_duration = 300
}
end
return M

View File

@ -71,7 +71,7 @@ function M.dashboard_conf()
button('SPC f d', 'ﱮ Recent directories'),
button('SPC f m', ' Bookmarks'),
button('SPC f p', ' Projects'),
button('SPC e l', ' Load last session')
button('SPC s l', ' Load last session')
},
opts = {spacing = 1}
}
@ -181,33 +181,46 @@ function M.statusline_conf()
hl = {fg = colors.fg, style = 'bold'},
right_sep = ' '
},
codeact = {
provider = function()
local present, state = pcall(require, 'nvim-lightbulb')
if present then
return state.get_status_text()
else
return ''
end
end,
hl = {fg = colors.green, style = 'bold'}
},
diagerr = {
provider = 'diagnostic_errors',
icon = '',
hl = {fg = colors.red},
right_sep = ' '
left_sep = ' '
},
diagwarn = {
provider = 'diagnostic_warnings',
icon = '',
icon = ' ',
hl = {fg = colors.yellow},
right_sep = ' '
left_sep = ' '
},
diaghint = {
provider = 'diagnostic_hints',
icon = ' ',
icon = ' ',
hl = {fg = colors.cyan},
right_sep = ' '
left_sep = ' '
},
diaginfo = {
provider = 'diagnostic_info',
icon = '',
hl = {fg = colors.blue}
hl = {fg = colors.blue},
left_sep = ' '
},
lspclient = {
provider = 'lsp_client_names',
icon = ' LSP:',
hl = {fg = colors.purple, style = 'bold'}
hl = {fg = colors.purple, style = 'bold'},
left_sep = ' '
},
format = {
provider = file_osinfo,
@ -268,10 +281,11 @@ function M.statusline_conf()
table.insert(components.active[1], comps.fileinfo)
table.insert(components.active[1], comps.lineinfo)
table.insert(components.active[1], comps.percent)
table.insert(components.active[1], comps.diagerr)
table.insert(components.active[1], comps.diagwarn)
table.insert(components.active[1], comps.diaghint)
table.insert(components.active[1], comps.diaginfo)
table.insert(components.active[3], comps.codeact)
table.insert(components.active[3], comps.diagerr)
table.insert(components.active[3], comps.diagwarn)
table.insert(components.active[3], comps.diaghint)
table.insert(components.active[3], comps.diaginfo)
table.insert(components.active[3], comps.lspclient)
table.insert(components.active[3], comps.format)
table.insert(components.active[3], comps.encode)
@ -351,9 +365,9 @@ function M.nvimtree_conf()
git = {
unstaged = '',
staged = '',
unmerged = '',
unmerged = '',
renamed = '',
untracked = '',
untracked = '',
deleted = '',
ignored = ''
},
@ -361,17 +375,11 @@ function M.nvimtree_conf()
arrow_open = '',
arrow_closed = '',
default = '',
open = '',
open = '',
empty = '',
empty_open = '',
symlink = '',
symlink_open = ''
},
lsp = {
hint = '',
info = '',
warning = '',
error = ''
symlink_open = ''
}
}
@ -386,7 +394,15 @@ function M.nvimtree_conf()
},
hijack_cursor = true,
update_cwd = true,
lsp_diagnostics = true,
diagnostics = {
enable = true,
icons = {
hint = '',
info = '',
warning = '',
error = ''
}
},
update_focused_file = {
enable = true,
update_cwd = true,

View File

@ -60,7 +60,8 @@ return packer.startup(function(use)
}
use {
'RRethy/vim-illuminate',
event = 'CursorHold'
event = 'CursorHold',
setup = editor.illuminate_conf
}
-- use { -- TODO: config (lua -> fennel) + learn clojure, fennel, guile scheme
-- 'Olical/conjure',
@ -73,6 +74,11 @@ return packer.startup(function(use)
event = 'BufRead',
config = editor.treesitter_conf
}
-- use {
-- 'lewis6991/spellsitter.nvim',
-- event = {'BufRead', 'BufNew', 'BufNewFile'},
-- config = editor.spellsitter_conf
-- }
use {
'lukas-reineke/indent-blankline.nvim',
after = 'nvim-treesitter',
@ -84,14 +90,8 @@ return packer.startup(function(use)
-- Putting config into `treesitter_conf` doesn't work for some reason
config = editor.rainbow_conf
}
use {
'romgrk/nvim-treesitter-context',
after = 'nvim-treesitter'
}
use {
'nvim-treesitter/nvim-treesitter-textobjects',
after = 'nvim-treesitter'
}
use {'romgrk/nvim-treesitter-context', after = 'nvim-treesitter'}
use {'nvim-treesitter/nvim-treesitter-textobjects', after = 'nvim-treesitter'}
use {
'mizlan/iswap.nvim',
cmd = {'ISwapWith', 'ISwap'},
@ -103,7 +103,24 @@ return packer.startup(function(use)
after = 'nvim-treesitter',
config = editor.matchup_conf
}
use {'machakann/vim-sandwich', keys = 's'}
use {'machakann/vim-sandwich', keys = 's'} -- TODO: check out surround.nvim
use {
'folke/zen-mode.nvim',
cmd = 'ZenMode',
wants = 'twilight.nvim',
requires = {{
'folke/twilight.nvim',
cmd = {'Twilight', 'TwilightEnable'},
config = editor.twilight_conf,
opt = true
}},
config = editor.zenmode_conf
}
use {
'max397574/better-escape.nvim',
event = 'InsertCharPre',
config = editor.betterescape_conf
}
use {
'phaazon/hop.nvim',
cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'},
@ -111,21 +128,28 @@ return packer.startup(function(use)
}
use {
'hrsh7th/vim-eft',
event = {'BufRead', 'BufNewFile'},
setup = editor.eft_conf
}
use {
'junegunn/vim-easy-align',
cmd = 'EasyAlign'
keys = {
{'n', 'f'}, {'x', 'f'}, {'n', 'F'}, {'x', 'F'},
{'n', 't'}, {'x', 't'}, {'n', 'T'}, {'x', 'T'},
{'n', ';'}, {'x', ';'}
},
config = editor.eft_conf
}
use {'junegunn/vim-easy-align', cmd = 'EasyAlign'}
use {
'terrortylor/nvim-comment',
keys = 'gc',
config = editor.comment_conf
}
use {
'danymat/neogen',
keys = '<leader>eg',
wants = 'nvim-treesitter',
config = editor.neogen_conf
}
use {
'editorconfig/editorconfig-vim',
event = {'BufNewFile', 'BufRead'}
event = {'BufRead', 'BufNewFile'}
}
use { -- TODO: move to nvim-parinfer (lua)
'eraserhd/parinfer-rust',
@ -137,6 +161,12 @@ return packer.startup(function(use)
event = 'BufEnter',
config = editor.project_conf
}
use {
'ruifm/gitlinker.nvim',
wants = 'plenary.nvim',
keys = {'<leader>gy', '<leader>gY'},
config = editor.gitlinker_conf
}
---------
-- LSP --
@ -155,6 +185,11 @@ return packer.startup(function(use)
wants = 'nvim-lspconfig',
config = lsp.sqls_conf
}
use {
'kosayoda/nvim-lightbulb',
after = 'nvim-lspconfig',
config = lsp.lightbulb_conf
}
use {
'folke/trouble.nvim',
cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'},
@ -179,9 +214,13 @@ return packer.startup(function(use)
}
use { -- TODO: config, scripts to install/update dap servers
'rcarriga/nvim-dap-ui',
event = 'BufReadPre',
keys = '<leader>d',
wants = 'nvim-dap',
requires = {{'mfussenegger/nvim-dap', config = lsp.dap_conf, opt = true}},
requires = {{
'mfussenegger/nvim-dap',
config = lsp.dap_conf,
opt = true
}},
config = lsp.dapui_conf
}
@ -312,13 +351,6 @@ return packer.startup(function(use)
run = 'npm install --prefix server',
cmd = 'Bracey'
}
use {
'folke/zen-mode.nvim',
cmd = 'ZenMode',
wants = 'twilight.nvim',
requires = {{'folke/twilight.nvim', opt = true}},
config = tools.zenmode_conf
}
use { -- shouldn't be lazy-loaded (global bindings don't work)
'kristijanhusak/orgmode.nvim',
ft = 'org',
@ -326,7 +358,7 @@ return packer.startup(function(use)
}
use {
'windwp/nvim-spectre',
event = {'BufRead', 'BufNewFile'},
keys = '<leader>p',
wants = 'plenary.nvim',
config = tools.spectre_conf
}
@ -373,18 +405,36 @@ return packer.startup(function(use)
}
use {
'folke/persistence.nvim',
event = 'BufEnter',
event = 'BufReadPre',
keys = '<leader>s',
config = tools.session_conf
}
use { -- Replace default filetype.vim
'nathom/filetype.nvim',
event = {'BufRead', 'BufNewFile'},
config = tools.filetype_conf
}
use {
'kazhala/close-buffers.nvim',
cmd = {'BDelete', 'BWipeout'},
wants = 'bufferline.nvim',
config = tools.closebuf_conf
}
use {
'sindrets/winshift.nvim',
cmd = 'WinShift',
config = tools.winshift_conf
}
use {
'ten3roberts/window-picker.nvim',
cmd = {'WindowPick', 'WindowSwap', 'WindowSwapStay'},
config = tools.winpicker_conf
}
use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking
-- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*,
-- nvim-bqf, nvim-comment-frame, nvim-revJ.lua, nvim-remote-containers,
-- tex.nvim, telescope-lsp-handlers.nvim
-- tex.nvim, telescope-lsp-handlers.nvim, telescope-dap.nvim
-- Install plugins if missing
packer.install()