nvim: big refactor
This commit is contained in:
parent
1d8717e374
commit
6945941009
|
@ -7,5 +7,5 @@ require('autocmd').setup()
|
|||
|
||||
-- packer_compiled.lua exists, so don't need to load this early
|
||||
vim.defer_fn(function()
|
||||
require('plugins')
|
||||
require('plugins').load_plugins()
|
||||
end, 0)
|
||||
|
|
|
@ -13,7 +13,6 @@ local augroups = {
|
|||
{'BufWritePre', '*.tmp', 'setlocal noundofile'},
|
||||
{'BufWritePre', '*.bak', 'setlocal noundofile'}
|
||||
},
|
||||
|
||||
wins = {
|
||||
-- Equalize window dimensions when resizing vim window
|
||||
{'VimResized', '*', 'tabdo wincmd ='},
|
||||
|
@ -22,26 +21,13 @@ local augroups = {
|
|||
-- Check if file changed when its window is focus, more eager than 'autoread'
|
||||
{'FocusGained', '* checktime'}
|
||||
},
|
||||
|
||||
yank = {
|
||||
{'TextYankPost', [[* silent! lua vim.highlight.on_yank({higroup='IncSearch', timeout=300})]]}
|
||||
}
|
||||
}
|
||||
|
||||
local load_autocmd = function(definitions)
|
||||
for group_name, definition in pairs(definitions) do
|
||||
vim.api.nvim_command('augroup ' .. group_name)
|
||||
vim.api.nvim_command('autocmd!')
|
||||
for _, def in ipairs(definition) do
|
||||
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
|
||||
vim.api.nvim_command(command)
|
||||
end
|
||||
vim.api.nvim_command('augroup END')
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
load_autocmd(augroups)
|
||||
require('util').load_autocmd(augroups)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,33 +1,30 @@
|
|||
local api = vim.api
|
||||
local wk = require('which-key')
|
||||
local M = {}
|
||||
local wk = require('which-key')
|
||||
local api, notify = vim.api, vim.notify
|
||||
local opts = {noremap = true, silent = true}
|
||||
|
||||
-------------------------------
|
||||
-- Globally defined mappings --
|
||||
-------------------------------
|
||||
local normal_mappings = {
|
||||
-- Better Y
|
||||
Y = {'y$', 'Yank to eol'},
|
||||
|
||||
-- Easier start and end of line
|
||||
H = {'^', 'Start of the line'},
|
||||
L = {'$', 'End of the line'},
|
||||
|
||||
-- Close a window
|
||||
['<C-q>'] = {'<C-w>q', 'Quit current window'},
|
||||
|
||||
-- Close current buffer
|
||||
['<A-q>'] = {':bdelete<CR>', 'Close current buffer'},
|
||||
|
||||
-- Copy the whole buffer
|
||||
['<A-a>'] = {':%y+<CR>', 'Copy whole buffer'},
|
||||
|
||||
-- Remove trailing whitespace
|
||||
['<A-w>'] = {':%s/\\s\\+$//e<CR>', 'Remove trailing'},
|
||||
|
||||
-- Resize buffer
|
||||
['<A-j>'] = {':resize -2<CR>', 'Resize vertical -2'},
|
||||
['<A-k>'] = {':resize +2<CR>', 'Resize vertical +2'},
|
||||
['<A-h>'] = {':vertical resize -2<CR>', 'Resize horizontal -2'},
|
||||
['<A-l>'] = {':vertical resize +2<CR>', 'Resize horizontal +2'},
|
||||
|
||||
-- Switch between tabs and spaces
|
||||
['<A-t>'] = {
|
||||
function()
|
||||
|
@ -35,17 +32,16 @@ local normal_mappings = {
|
|||
vim.opt.expandtab = false
|
||||
vim.opt.smarttab = false
|
||||
vim.opt.softtabstop = 0 -- reset to default
|
||||
vim.notify('Indent with Tabs.', vim.log.levels.INFO)
|
||||
notify('Indent with Tabs.', vim.log.levels.INFO)
|
||||
else
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.smarttab = true
|
||||
vim.opt.softtabstop = -1 -- fallback to shiftwidth
|
||||
vim.notify('Indent with Spaces.', vim.log.levels.INFO)
|
||||
notify('Indent with Spaces.', vim.log.levels.INFO)
|
||||
end
|
||||
end,
|
||||
'Switch indent style'
|
||||
},
|
||||
|
||||
-- Naming common keys
|
||||
['['] = {
|
||||
name = 'Block motions (previous)',
|
||||
|
@ -60,15 +56,12 @@ local normal_mappings = {
|
|||
t = {':TodoTrouble<CR>', 'Todo list'}
|
||||
},
|
||||
z = {name = 'Misc utils'},
|
||||
|
||||
-- Move between tabs
|
||||
['<TAB>'] = {':BufferLineCycleNext<CR>', 'Next buffer'},
|
||||
['<S-TAB>'] = {':BufferLineCyclePrev<CR>', 'Previous buffer'},
|
||||
|
||||
-- ToggleTerm
|
||||
['<C-\\>'] = {':ToggleTerm<CR>', 'Toggle terminal'},
|
||||
['<A-\\>'] = {':ToggleTerm direction=float<CR>', 'Toggle float terminal'},
|
||||
|
||||
-- hop.nvim
|
||||
S = {':HopWord<CR>', 'Hop to word'},
|
||||
['<C-s>'] = {':HopChar1<CR>', 'Hop to character'},
|
||||
|
@ -93,7 +86,6 @@ local normal_leader_mappings = {
|
|||
v = 'Run again 1 step',
|
||||
z = 'Re-run the last adapter'
|
||||
},
|
||||
|
||||
e = {
|
||||
name = 'Editor',
|
||||
a = {':EasyAlign<CR>', 'Align elements'},
|
||||
|
@ -106,24 +98,24 @@ local normal_leader_mappings = {
|
|||
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
||||
if venn_enabled == 'nil' then
|
||||
vim.b.venn_enabled = true
|
||||
vim.api.nvim_command('setlocal virtualedit=all')
|
||||
api.nvim_command('setlocal virtualedit=all')
|
||||
-- Draw lines with WASD keystroke
|
||||
vim.api.nvim_buf_set_keymap(0, 'n', 'A', '<C-v>h:VBox<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_buf_set_keymap(0, 'n', 'S', '<C-v>j:VBox<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_buf_set_keymap(0, 'n', 'W', '<C-v>k:VBox<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_buf_set_keymap(0, 'n', 'D', '<C-v>l:VBox<CR>', {noremap = true, silent = true})
|
||||
api.nvim_buf_set_keymap(0, 'n', 'A', '<C-v>h:VBox<CR>', opts)
|
||||
api.nvim_buf_set_keymap(0, 'n', 'S', '<C-v>j:VBox<CR>', opts)
|
||||
api.nvim_buf_set_keymap(0, 'n', 'W', '<C-v>k:VBox<CR>', opts)
|
||||
api.nvim_buf_set_keymap(0, 'n', 'D', '<C-v>l:VBox<CR>', opts)
|
||||
-- Draw boxes by pressing 'f' with visual selection
|
||||
vim.api.nvim_buf_set_keymap(0, 'v', 'f', ':VBox<CR>', {noremap = true, silent = true})
|
||||
vim.notify('Virtual box edit enabled.', vim.log.levels.INFO)
|
||||
api.nvim_buf_set_keymap(0, 'v', 'f', ':VBox<CR>', opts)
|
||||
notify('Virtual box edit enabled.', vim.log.levels.INFO)
|
||||
else
|
||||
vim.b.venn_enabled = nil
|
||||
vim.api.nvim_command('setlocal virtualedit=block')
|
||||
vim.api.nvim_buf_del_keymap(0, 'v', 'f')
|
||||
vim.api.nvim_buf_del_keymap(0, 'n', 'A')
|
||||
vim.api.nvim_buf_del_keymap(0, 'n', 'S')
|
||||
vim.api.nvim_buf_del_keymap(0, 'n', 'W')
|
||||
vim.api.nvim_buf_del_keymap(0, 'n', 'D')
|
||||
vim.notify('Virtual box edit disabled.', vim.log.levels.INFO)
|
||||
api.nvim_command('setlocal virtualedit=block')
|
||||
api.nvim_buf_del_keymap(0, 'v', 'f')
|
||||
api.nvim_buf_del_keymap(0, 'n', 'A')
|
||||
api.nvim_buf_del_keymap(0, 'n', 'S')
|
||||
api.nvim_buf_del_keymap(0, 'n', 'W')
|
||||
api.nvim_buf_del_keymap(0, 'n', 'D')
|
||||
notify('Virtual box edit disabled.', vim.log.levels.INFO)
|
||||
end
|
||||
end,
|
||||
'Toggle virtual box edit'
|
||||
|
@ -131,8 +123,6 @@ local normal_leader_mappings = {
|
|||
z = {':ZenMode<CR>', 'Zen mode'},
|
||||
Z = {':Twilight<CR>', 'Twilight mode'}
|
||||
},
|
||||
|
||||
-- Telescope
|
||||
f = {
|
||||
name = 'Telescope',
|
||||
a = {':Telescope autocommands<CR>', 'Autocommands'},
|
||||
|
@ -176,8 +166,6 @@ local normal_leader_mappings = {
|
|||
y = {':Telescope filetypes<CR>', 'Filetypes'},
|
||||
z = {':Telescope registers<CR>', 'Vim registers'}
|
||||
},
|
||||
|
||||
-- Git
|
||||
g = {
|
||||
name = 'Git',
|
||||
a = {':Telescope git_stash<CR>', 'Stash'},
|
||||
|
@ -197,8 +185,6 @@ local normal_leader_mappings = {
|
|||
y = 'Get remote url for cursorline',
|
||||
Y = 'Get remote url'
|
||||
},
|
||||
|
||||
-- translate-shell.vim
|
||||
j = {
|
||||
name = 'Translate',
|
||||
t = {':Trans<CR>', 'Translate'},
|
||||
|
@ -206,24 +192,19 @@ local normal_leader_mappings = {
|
|||
r = {'cw<C-R>=system(\'trans -brief -no-ansi\', getreg(""))[:-2]<CR>', 'Translate and replace'},
|
||||
c = {'cw<C-R>=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]<S-Left><S-Left><Right>', 'Translate and replace with direction'}
|
||||
},
|
||||
|
||||
-- NvimTree
|
||||
n = {':NvimTreeToggle<CR>', 'NvimTree'},
|
||||
|
||||
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'},
|
||||
p = {'<Plug>RestNvimPreview', 'Preview request cURL command'},
|
||||
l = {'<Plug>RestNvimLast', 'Re-run last request'}
|
||||
},
|
||||
|
||||
s = {
|
||||
name = 'Session',
|
||||
s = 'Save session for current directory',
|
||||
|
@ -231,9 +212,7 @@ local normal_leader_mappings = {
|
|||
l = 'Load last session',
|
||||
r = 'Load session for current directory'
|
||||
},
|
||||
|
||||
w = {':WindowPick<CR>', 'Pick window'}
|
||||
|
||||
}
|
||||
|
||||
local visual_leader_mappings = {
|
||||
|
@ -241,19 +220,16 @@ local visual_leader_mappings = {
|
|||
name = 'Editor',
|
||||
a = {':EasyAlign<CR>', 'Range align'}
|
||||
},
|
||||
|
||||
d = {
|
||||
name = 'DAP',
|
||||
e = 'Hover on range (UI)'
|
||||
},
|
||||
|
||||
g = {
|
||||
name = 'Git',
|
||||
r = 'Reset hunk',
|
||||
s = 'Stage hunk',
|
||||
y = 'Get remote url for range'
|
||||
},
|
||||
|
||||
j = {
|
||||
name = 'Translate',
|
||||
t = {':Trans<CR>', 'Translate'},
|
||||
|
@ -261,14 +237,13 @@ local visual_leader_mappings = {
|
|||
r = {'c<C-R>=system(\'trans -brief -no-ansi\', getreg(""))[:-2]<CR>', 'Translate and replace'},
|
||||
c = {'c<C-R>=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]<S-Left><S-Left><Right>', 'Translate and replace with direction'}
|
||||
},
|
||||
|
||||
p = 'Find/Replace'
|
||||
}
|
||||
|
||||
local localleader_mappings = function()
|
||||
vim.api.nvim_command('autocmd BufEnter * lua WhichkeyLocal()')
|
||||
local function localleader_mappings()
|
||||
api.nvim_command('autocmd BufEnter * lua WhichkeyLocal()')
|
||||
function WhichkeyLocal()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
wk.register({
|
||||
c = {':ColorizerToggle<CR>', 'Colorizer'},
|
||||
d = {
|
||||
|
@ -286,40 +261,37 @@ local localleader_mappings = function()
|
|||
}, {buffer = bufnr, prefix = '<localleader>'})
|
||||
end
|
||||
|
||||
vim.api.nvim_command('autocmd FileType markdown lua WhichkeyMarkdown()')
|
||||
api.nvim_command('autocmd FileType markdown lua WhichkeyMarkdown()')
|
||||
function WhichkeyMarkdown()
|
||||
wk.register({
|
||||
p = {':MarkdownPreviewToggle<CR>', 'Preview markdown'}
|
||||
}, {buffer = vim.api.nvim_get_current_buf(), prefix = '<localleader>'})
|
||||
}, {buffer = api.nvim_get_current_buf(), prefix = '<localleader>'})
|
||||
end
|
||||
|
||||
vim.api.nvim_command('autocmd FileType html lua WhichkeyHtml()')
|
||||
api.nvim_command('autocmd FileType html lua WhichkeyHtml()')
|
||||
function WhichkeyHtml()
|
||||
wk.register({
|
||||
p = {':Bracey<CR>', 'Preview html'}
|
||||
}, {buffer = vim.api.nvim_get_current_buf(), prefix = '<localleader>'})
|
||||
}, {buffer = api.nvim_get_current_buf(), prefix = '<localleader>'})
|
||||
end
|
||||
end
|
||||
|
||||
local undefined_mappings = function()
|
||||
local function undefined_mappings()
|
||||
-- Escape to normal mode in terminal buffer
|
||||
api.nvim_set_keymap('t', '<Esc>', '<C-\\><C-n>', {noremap = true, silent = true})
|
||||
|
||||
api.nvim_set_keymap('t', '<Esc>', '<C-\\><C-n>', opts)
|
||||
-- Continuous indent
|
||||
api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true})
|
||||
api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true})
|
||||
|
||||
api.nvim_set_keymap('v', '<', '<gv', opts)
|
||||
api.nvim_set_keymap('v', '>', '>gv', opts)
|
||||
-- Also move up/down virtual lines (:set wrap)
|
||||
api.nvim_set_keymap('n', 'j', 'gj', {noremap = true, silent = true})
|
||||
api.nvim_set_keymap('n', 'k', 'gk', {noremap = true, silent = true})
|
||||
|
||||
api.nvim_set_keymap('n', 'j', 'gj', opts)
|
||||
api.nvim_set_keymap('n', 'k', 'gk', opts)
|
||||
-- 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})
|
||||
api.nvim_set_keymap('n', '<C-w><C-m>', ':WinShift<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<C-w>m', ':WinShift<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<C-A-h>', ':WinShift left<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<C-A-j>', ':WinShift down<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<C-A-k>', ':WinShift up<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<C-A-l>', ':WinShift right<CR>', opts)
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
|
@ -330,4 +302,182 @@ function M.setup()
|
|||
wk.register(visual_leader_mappings, {mode = 'v', prefix = '<leader>'})
|
||||
end
|
||||
|
||||
-----------------------
|
||||
-- Plugins' mappings --
|
||||
-----------------------
|
||||
function M.orgmode()
|
||||
api.nvim_command('autocmd FileType org lua WhichkeyOrg()')
|
||||
function WhichkeyOrg()
|
||||
wk.register({
|
||||
['<leader>o'] = {
|
||||
name = 'Org',
|
||||
a = 'Agenda',
|
||||
A = 'Toggle ARCHIVE',
|
||||
c = 'Capture',
|
||||
e = 'Export',
|
||||
i = {
|
||||
name = 'Insert',
|
||||
h = 'Add headline',
|
||||
t = 'Add TODO heading and content',
|
||||
T = 'Add TODO heading'
|
||||
},
|
||||
J = 'Move subtree down',
|
||||
K = 'Move subtree up',
|
||||
o = 'Open at point',
|
||||
r = 'Refile',
|
||||
t = 'Set tags',
|
||||
['$'] = 'Archive current headline'
|
||||
},
|
||||
['<leader><CR>'] = 'Org meta return',
|
||||
['<C-a>'] = 'Org increase date',
|
||||
['<C-x>'] = 'Org decrease date',
|
||||
['cid'] = 'Org change date',
|
||||
['cit'] = 'Org TODO',
|
||||
['ciT'] = 'Org TODO prev',
|
||||
['<C-Space>'] = 'Org toggle checkbox',
|
||||
['<TAB>'] = 'Org cycle folding',
|
||||
['<S-TAB>'] = 'Org cycle global folding',
|
||||
['<<'] = 'Org promote headline',
|
||||
['>>'] = 'Org demote headline',
|
||||
['<s'] = 'Org prmote subtree',
|
||||
['>s'] = 'Org demote subtree',
|
||||
['}'] = 'Org next visible heading',
|
||||
['{'] = 'Org previous visible heading',
|
||||
[']]'] = 'Org forward heading',
|
||||
['[['] = 'Org backward heading',
|
||||
['g{'] = 'Org parent heading',
|
||||
['?'] = 'Org help'
|
||||
}, {buffer = api.nvim_get_current_buf()})
|
||||
end
|
||||
end
|
||||
|
||||
function M.treesitter()
|
||||
local mappings = {
|
||||
['['] = {
|
||||
m = 'Previous start of outer class',
|
||||
M = 'Previous end of outer class',
|
||||
['['] = 'Previous start of outer function',
|
||||
[']'] = 'Previous end of outer function'
|
||||
},
|
||||
[']'] = {
|
||||
m = 'Next start of outer class',
|
||||
M = 'Next end of outer class',
|
||||
['['] = 'Next start of outer function',
|
||||
[']'] = 'Next end of outer function'
|
||||
},
|
||||
g = {
|
||||
n = {
|
||||
name = 'Treesitter',
|
||||
d = 'Goto definition',
|
||||
D = 'List definitions',
|
||||
i = 'Initialize selection',
|
||||
j = 'Goto previous usage',
|
||||
k = 'Goto next usage',
|
||||
o = 'List definitions TOC',
|
||||
r = 'Rename within scope'
|
||||
}
|
||||
}
|
||||
}
|
||||
local visual_mappings = {
|
||||
a = {
|
||||
c = 'Outer class',
|
||||
f = 'Outer function'
|
||||
},
|
||||
i = {
|
||||
c = 'Inner class',
|
||||
f = 'Inner function'
|
||||
},
|
||||
g = {
|
||||
n = {
|
||||
name = 'Treesitter',
|
||||
n = 'Increment node',
|
||||
s = 'Increment scope',
|
||||
m = 'Decrement node'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wk.register(mappings)
|
||||
wk.register(visual_mappings, {mode = 'v'})
|
||||
end
|
||||
|
||||
function M.eft()
|
||||
api.nvim_set_keymap('n', 'f', '<Plug>(eft-f)', {silent = true})
|
||||
api.nvim_set_keymap('x', 'f', '<Plug>(eft-f)', {silent = true})
|
||||
api.nvim_set_keymap('n', 'F', '<Plug>(eft-F)', {silent = true})
|
||||
api.nvim_set_keymap('x', 'F', '<Plug>(eft-F)', {silent = true})
|
||||
api.nvim_set_keymap('n', 't', '<Plug>(eft-t)', {silent = true})
|
||||
api.nvim_set_keymap('x', 't', '<Plug>(eft-t)', {silent = true})
|
||||
api.nvim_set_keymap('n', 'T', '<Plug>(eft-T)', {silent = true})
|
||||
api.nvim_set_keymap('x', 'T', '<Plug>(eft-T)', {silent = true})
|
||||
api.nvim_set_keymap('n', ';', '<Plug>(eft-repeat)', {silent = true})
|
||||
api.nvim_set_keymap('x', ';', '<Plug>(eft-repeat)', {silent = true})
|
||||
end
|
||||
|
||||
function M.dial()
|
||||
api.nvim_set_keymap('n', '<C-a>', '<Plug>(dial-increment)', {silent = true})
|
||||
api.nvim_set_keymap('v', '<C-a>', '<Plug>(dial-increment)', {silent = true})
|
||||
api.nvim_set_keymap('n', '<C-x>', '<Plug>(dial-decrement)', {silent = true})
|
||||
api.nvim_set_keymap('v', '<C-x>', '<Plug>(dial-decrement)', {silent = true})
|
||||
api.nvim_set_keymap('v', 'g<C-a>', '<Plug>(dial-increment-additional)', {silent = true})
|
||||
api.nvim_set_keymap('v', 'g<C-x>', '<Plug>(dial-decrement-additional)', {silent = true})
|
||||
end
|
||||
|
||||
function M.neogen()
|
||||
api.nvim_set_keymap('n', '<leader>eg', ':lua require("neogen").generate()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<C-e>', ':lua require("neogen").jump_next()<CR>', opts)
|
||||
end
|
||||
|
||||
function M.gitlinker()
|
||||
api.nvim_set_keymap('n', '<leader>gY', ':lua require("gitlinker").get_repo_url()<CR>', opts)
|
||||
end
|
||||
|
||||
function M.dap()
|
||||
api.nvim_set_keymap('n', '<leader>dn', ':lua require("dap").continue()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>dd', ':lua require("dap").disconnect()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>db', ':lua require("dap").toggle_breakpoint()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>dB', ':lua require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>dl', ':lua require("dap").list_breakpoints()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>dc', ':lua require("dap").run_to_cursor()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>dz', ':lua require("dap").run_last()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<F9>', ':lua require("dap").step_over()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>dv', ':lua require("dap").step_over()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<F10>', ':lua require("dap").step_into()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>di', ':lua require("dap").step_into()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<F11>', ':lua require("dap").step_out()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>do', ':lua require("dap").step_out()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>dr', ':lua require("dap").repl.open()<CR>', opts)
|
||||
end
|
||||
|
||||
function M.dapui()
|
||||
api.nvim_set_keymap('n', '<leader>de', ':lua require("dapui").eval()<CR>', opts)
|
||||
api.nvim_set_keymap('v', '<leader>de', ':lua require("dapui").eval()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>df', ':lua require("dapui").float_element()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>dt', ':lua require("dapui").toggle()<CR>', opts)
|
||||
end
|
||||
|
||||
function M.telescope_symbols()
|
||||
api.nvim_set_keymap('n', '<leader>fjg', ':lua require("telescope.builtin").symbols{sources = {"gitmoji"}, prompt_title = "Gitmoji"}<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>fjj', ':lua require("telescope.builtin").symbols{sources = {"emoji"}, prompt_title = "Emoji"}<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>fjk', ':lua require("telescope.builtin").symbols{sources = {"kaomoji"}, prompt_title = "Kaomoji"}<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>fjl', ':lua require("telescope.builtin").symbols{sources = {"julia"}, prompt_title = "Julia symbols"}<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>fjm', ':lua require("telescope.builtin").symbols{sources = {"math"}, prompt_title = "Math symbols"}<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>fjn', ':lua require("telescope.builtin").symbols{sources = {"nerd"}, prompt_title = "Nerd-fonts symbols"}<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>fjt', ':lua require("telescope.builtin").symbols{sources = {"latex"}, prompt_title = "Latex symbols"}<CR>', opts)
|
||||
end
|
||||
|
||||
function M.spectre()
|
||||
api.nvim_set_keymap('n', '<leader>po', ':lua require("spectre").open()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>pp', 'viw:lua require("spectre").open_file_search()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>pw', ':lua require("spectre").open_visual({select_word = true})<CR>', opts)
|
||||
api.nvim_set_keymap('v', '<leader>p', ':lua require("spectre").open_visual()<CR>', opts)
|
||||
end
|
||||
|
||||
function M.persistence()
|
||||
api.nvim_set_keymap('n', '<leader>ss', ':lua require("persistence").save()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>sd', ':lua require("persistence").stop()<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>sl', ':lua require("persistence").load({last = true})<CR>', opts)
|
||||
api.nvim_set_keymap('n', '<leader>sr', ':lua require("persistence").load()<CR>', opts)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
local M = {}
|
||||
|
||||
function M.cmp_conf()
|
||||
function M.luasnip()
|
||||
local types = require('luasnip.util.types')
|
||||
|
||||
require('luasnip').config.set_config({
|
||||
updateevents = 'TextChanged, TextChangedI',
|
||||
history = true,
|
||||
ext_opts = {
|
||||
[types.choiceNode] = {
|
||||
active = {virt_text = {{'●', 'LuaSnipChoice'}}}
|
||||
},
|
||||
[types.insertNode] = {
|
||||
active = {virt_text = {{'●', 'LuaSnipInsert'}}}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
-- Loading snippets from 'friendly-snippets'
|
||||
require('luasnip/loaders/from_vscode').load()
|
||||
end
|
||||
|
||||
function M.cmp()
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
|
@ -61,7 +81,7 @@ function M.cmp_conf()
|
|||
orgmode = '[ORG]',
|
||||
-- cmp_tabnine = '[TN]',
|
||||
latex_symbols = '[TEX]',
|
||||
dictionary = '[DICT]',
|
||||
-- dictionary = '[DICT]',
|
||||
path = '[PATH]',
|
||||
buffer = '[BUF]',
|
||||
calc = '[CALC]'
|
||||
|
@ -74,27 +94,30 @@ function M.cmp_conf()
|
|||
border = { '┌','─', '┐', '│', '┘', '─', '└', '│'}
|
||||
},
|
||||
mapping = {
|
||||
['<CR>'] = cmp.mapping.confirm({select = true}),
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true
|
||||
}),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Insert}),
|
||||
['<C-n>'] = cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Insert}),
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-d>'] = cmp.mapping.close(),
|
||||
['<C-c>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.close()
|
||||
else fallback() end
|
||||
end),
|
||||
-- Change choice nodes for luasnip
|
||||
['<C-j>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.choice_active() then
|
||||
luasnip.change_choice(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
else fallback() end
|
||||
end, {'i', 's'}),
|
||||
['<C-k>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.choice_active() then
|
||||
luasnip.change_choice(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
else fallback() end
|
||||
end, {'i', 's'}),
|
||||
-- supertab-like mapping
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
|
@ -104,18 +127,14 @@ function M.cmp_conf()
|
|||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
else fallback() end
|
||||
end, {'i', 's'}),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
else fallback() end
|
||||
end, {'i', 's'})
|
||||
},
|
||||
snippet = {
|
||||
|
@ -130,7 +149,7 @@ function M.cmp_conf()
|
|||
{name = 'orgmode'},
|
||||
-- {name = 'cmp_tabnine'},
|
||||
{name = 'latex_symbols'},
|
||||
{name = 'dictionary', keyword_length = 2},
|
||||
-- {name = 'dictionary', keyword_length = 2},
|
||||
{name = 'path'},
|
||||
{name = 'buffer'},
|
||||
{name = 'calc'}
|
||||
|
@ -141,7 +160,7 @@ function M.cmp_conf()
|
|||
vim.g.cmp_dictionary_exact = -1
|
||||
end
|
||||
|
||||
-- function M.tabnine_conf()
|
||||
-- function M.tabnine()
|
||||
-- local tabnine = require('cmp_tabnine.config')
|
||||
-- tabnine:setup {
|
||||
-- max_lines = 1000,
|
||||
|
@ -151,7 +170,7 @@ end
|
|||
-- }
|
||||
-- end
|
||||
|
||||
function M.autopairs_conf()
|
||||
function M.autopairs()
|
||||
require('nvim-autopairs').setup {
|
||||
disable_filetype = {'TelescopePrompt', 'spectre_panel'},
|
||||
disable_in_macro = false, -- disable when recording or executing a macro
|
||||
|
@ -186,28 +205,4 @@ function M.autopairs_conf()
|
|||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||
end
|
||||
|
||||
function M.snippets_conf()
|
||||
local types = require('luasnip.util.types')
|
||||
|
||||
require('luasnip').config.set_config({
|
||||
updateevents = 'TextChanged, TextChangedI',
|
||||
history = true,
|
||||
ext_opts = {
|
||||
[types.choiceNode] = {
|
||||
active = {
|
||||
virt_text = {{'●', 'LuaSnipChoice'}}
|
||||
}
|
||||
},
|
||||
[types.insertNode] = {
|
||||
active = {
|
||||
virt_text = {{'●', 'LuaSnipInsert'}}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
-- Loading vscode-like snippets from 'friendly-snippets'
|
||||
require('luasnip/loaders/from_vscode').load()
|
||||
end
|
||||
|
||||
return M
|
|
@ -0,0 +1,35 @@
|
|||
local M = {}
|
||||
local conf = require('modules.completion.config')
|
||||
|
||||
M['hrsh7th/nvim-cmp'] = {
|
||||
event = 'InsertEnter',
|
||||
wants = {'LuaSnip', 'cmp-under-comparator'},
|
||||
requires = {
|
||||
{
|
||||
'L3MON4D3/LuaSnip',
|
||||
wants = 'friendly-snippets',
|
||||
requires = {{'rafamadriz/friendly-snippets', opt = true}},
|
||||
config = conf.luasnip,
|
||||
opt = true
|
||||
},
|
||||
{'lukas-reineke/cmp-under-comparator', opt = true}
|
||||
},
|
||||
config = conf.cmp
|
||||
}
|
||||
M['saadparwaiz1/cmp_luasnip'] = {after = 'nvim-cmp'}
|
||||
M['saadparwaiz1/cmp_luasnip'] = {after = 'nvim-cmp'}
|
||||
M['hrsh7th/cmp-path'] = {after = 'nvim-cmp'}
|
||||
M['hrsh7th/cmp-buffer'] = {after = 'nvim-cmp'}
|
||||
M['hrsh7th/cmp-calc'] = {after = 'nvim-cmp'}
|
||||
M['uga-rosa/cmp-dictionary'] = {after = 'nvim-cmp'}
|
||||
M['hrsh7th/cmp-nvim-lsp'] = {after = {'nvim-cmp', 'nvim-lspconfig'}}
|
||||
-- M['tzachar/cmp-tabnine'] = {
|
||||
-- after = 'nvim-cmp',
|
||||
-- run = './install.sh',
|
||||
-- config = conf.tabnine
|
||||
-- }
|
||||
M['kdheepak/cmp-latex-symbols'] = {after = 'nvim-cmp'}
|
||||
M['PaterJason/cmp-conjure'] = {after = {'conjure', 'nvim-cmp'}}
|
||||
M['windwp/nvim-autopairs'] = {after = 'nvim-cmp', config = conf.autopairs}
|
||||
|
||||
return M
|
|
@ -0,0 +1,29 @@
|
|||
local M = {}
|
||||
|
||||
function M.notify()
|
||||
require('notify').setup {
|
||||
-- Animation style (see below for details)
|
||||
stages = 'fade_in_slide_out',
|
||||
-- Function called when a new window is opened, use for changing win settings/config
|
||||
on_open = nil,
|
||||
-- Render function for notifications. See notify-render()
|
||||
render = 'default',
|
||||
-- Default timeout for notifications
|
||||
timeout = 2000,
|
||||
-- For stages that change opacity this is treated as the highlight behind the window
|
||||
-- Set this to either a highlight group or an RGB hex value e.g. '#000000'
|
||||
background_colour = 'NormalFloat',
|
||||
-- Minimum width for notification windows
|
||||
minimum_width = 40,
|
||||
-- Icons for the different levels
|
||||
icons = {
|
||||
ERROR = '',
|
||||
WARN = '',
|
||||
INFO = '',
|
||||
DEBUG = '',
|
||||
TRACE = '✎'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,7 +1,7 @@
|
|||
local fn, api = vim.fn, vim.api
|
||||
local fn, cmd = vim.fn, vim.api.nvim_command
|
||||
|
||||
-- Require since we use 'packer' as opt
|
||||
api.nvim_command('packadd packer.nvim')
|
||||
cmd('packadd packer.nvim')
|
||||
local present, packer = pcall(require, 'packer')
|
||||
|
||||
if not present then
|
||||
|
@ -11,7 +11,7 @@ if not present then
|
|||
-- remove packer_dir before cloning
|
||||
fn.delete(packer_dir, 'rf')
|
||||
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', packer_dir})
|
||||
api.nvim_command('packadd packer.nvim')
|
||||
cmd('packadd packer.nvim')
|
||||
present, packer = pcall(require, 'packer')
|
||||
|
||||
if present then
|
||||
|
@ -57,9 +57,9 @@ _G.packer_compile_on_save = function()
|
|||
local config_dir = fn.stdpath('config') .. '/lua/modules'
|
||||
|
||||
if file:match(config_dir) and filename ~= 'pack.lua' then
|
||||
vim.api.nvim_command('source <afile> | PackerCompile')
|
||||
cmd('source <afile> | PackerCompile')
|
||||
end
|
||||
end
|
||||
api.nvim_command('autocmd BufWritePost *.lua lua packer_compile_on_save()')
|
||||
cmd('autocmd BufWritePost *.lua lua packer_compile_on_save()')
|
||||
|
||||
return packer
|
|
@ -0,0 +1,10 @@
|
|||
local conf = require('modules.core.config')
|
||||
local M = {
|
||||
['wbthomason/packer.nvim'] = {opt = true},
|
||||
['kyazdani42/nvim-web-devicons'] = {module = 'nvim-web-devicons'},
|
||||
['nvim-lua/plenary.nvim'] = {module = 'plenary'},
|
||||
['nvim-lua/popup.nvim'] = {module = 'popup'},
|
||||
['rcarriga/nvim-notify'] = {module = 'nvim-notify', config = conf.notify}
|
||||
}
|
||||
|
||||
return M
|
|
@ -1,6 +1,6 @@
|
|||
local M = {}
|
||||
|
||||
function M.colorizer_conf()
|
||||
function M.colorizer()
|
||||
require('colorizer').setup(
|
||||
{'*'},
|
||||
{
|
||||
|
@ -16,40 +16,19 @@ function M.colorizer_conf()
|
|||
})
|
||||
end
|
||||
|
||||
-- function M.illuminate_conf()
|
||||
-- function M.illuminate()
|
||||
-- vim.g.Illuminate_delay = 500
|
||||
-- vim.g.Illuminate_ftblacklist = {'alpha', 'NvimTree', 'undotree', 'packer'}
|
||||
-- end
|
||||
|
||||
function M.blankline_conf()
|
||||
require('indent_blankline').setup {
|
||||
char = '│',
|
||||
-- space_char_blankline = '·',
|
||||
show_first_indent_level = true,
|
||||
filetype_exclude = {
|
||||
'startify', 'dashboard', 'alpha', 'log', 'gitcommit', 'packer', 'vimwiki',
|
||||
'markdown', 'org', 'json', 'txt', 'help', 'NvimTree', 'git', 'TelescopePrompt',
|
||||
'undotree', 'dotooagenda', 'fugitive',
|
||||
'' -- for all buffers without a filetype
|
||||
},
|
||||
buftype_exclude = {'terminal', 'nofile'},
|
||||
show_trailing_blankline_indent = false,
|
||||
-- show_end_of_line = true,
|
||||
show_current_context = true,
|
||||
context_patterns = {
|
||||
'class', 'function', 'method', 'block', 'list_literal', 'selector', '^if',
|
||||
'^table', 'if_statement', 'while', 'for'
|
||||
},
|
||||
use_treesitter = true
|
||||
function M.org_bullets()
|
||||
require('org-bullets').setup {
|
||||
symbols = {'', '', '', ''}
|
||||
}
|
||||
|
||||
-- Refresh often, since it is lazy-loaded
|
||||
-- vim.api.nvim_command('autocmd CursorMoved * IndentBlanklineRefresh')
|
||||
end
|
||||
|
||||
function M.orgmode_conf()
|
||||
function M.orgmode()
|
||||
local c = require('themes.' .. vim.g.colors_name .. '.colors')
|
||||
|
||||
require('orgmode').setup {
|
||||
-- General settings
|
||||
org_agenda_files = {'~/Documents/Org/agenda/*'},
|
||||
|
@ -84,60 +63,10 @@ function M.orgmode_conf()
|
|||
org_use_tag_inheritance = false
|
||||
}
|
||||
|
||||
-- Define mappings's names
|
||||
vim.api.nvim_command('autocmd FileType org lua WhichkeyOrg()')
|
||||
local wk = require('which-key')
|
||||
function WhichkeyOrg()
|
||||
wk.register({
|
||||
['<leader>o'] = {
|
||||
name = 'Org',
|
||||
a = 'Agenda',
|
||||
A = 'Toggle ARCHIVE',
|
||||
c = 'Capture',
|
||||
e = 'Export',
|
||||
i = {
|
||||
name = 'Insert',
|
||||
h = 'Add headline',
|
||||
t = 'Add TODO heading and content',
|
||||
T = 'Add TODO heading'
|
||||
},
|
||||
J = 'Move subtree down',
|
||||
K = 'Move subtree up',
|
||||
o = 'Open at point',
|
||||
r = 'Refile',
|
||||
t = 'Set tags',
|
||||
['$'] = 'Archive current headline'
|
||||
},
|
||||
['<leader><CR>'] = 'Org meta return',
|
||||
['<C-a>'] = 'Org increase date',
|
||||
['<C-x>'] = 'Org decrease date',
|
||||
['cid'] = 'Org change date',
|
||||
['cit'] = 'Org TODO',
|
||||
['ciT'] = 'Org TODO prev',
|
||||
['<C-Space>'] = 'Org toggle checkbox',
|
||||
['<TAB>'] = 'Org cycle folding',
|
||||
['<S-TAB>'] = 'Org cycle global folding',
|
||||
['<<'] = 'Org promote headline',
|
||||
['>>'] = 'Org demote headline',
|
||||
['<s'] = 'Org prmote subtree',
|
||||
['>s'] = 'Org demote subtree',
|
||||
['}'] = 'Org next visible heading',
|
||||
['{'] = 'Org previous visible heading',
|
||||
[']]'] = 'Org forward heading',
|
||||
['[['] = 'Org backward heading',
|
||||
['g{'] = 'Org parent heading',
|
||||
['?'] = 'Org help'
|
||||
}, {buffer = vim.api.nvim_get_current_buf()})
|
||||
end
|
||||
require('mappings').orgmode()
|
||||
end
|
||||
|
||||
function M.bullets_conf()
|
||||
require('org-bullets').setup {
|
||||
symbols = {'', '', '', ''}
|
||||
}
|
||||
end
|
||||
|
||||
function M.headlines_conf()
|
||||
function M.headlines()
|
||||
require('headlines').setup {
|
||||
markdown = {
|
||||
headline_signs = false,
|
||||
|
@ -152,7 +81,7 @@ function M.headlines_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.treesitter_conf()
|
||||
function M.treesitter()
|
||||
-- Additional parser for rest.nvim (*.http files)
|
||||
local parser_configs = require('nvim-treesitter.parsers').get_parser_configs()
|
||||
parser_configs.http = {
|
||||
|
@ -166,7 +95,8 @@ function M.treesitter_conf()
|
|||
install_info = {
|
||||
url = 'https://github.com/milisims/tree-sitter-org',
|
||||
revision = 'main',
|
||||
files = {'src/parser.c', 'src/scanner.cc'}
|
||||
files = {'src/parser.c', 'src/scanner.cc'},
|
||||
branch = 'master'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,7 +115,7 @@ function M.treesitter_conf()
|
|||
node_decremental = 'gnm'
|
||||
}
|
||||
},
|
||||
indent = {enable = true},
|
||||
indent = {enable = false},
|
||||
refactor = {
|
||||
highlight_definitions = {enable = true},
|
||||
highlight_current_scope = {enable = false},
|
||||
|
@ -286,65 +216,55 @@ function M.treesitter_conf()
|
|||
vim.opt.foldmethod = 'expr'
|
||||
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||
|
||||
-- Define mappings' names
|
||||
local wk = require('which-key')
|
||||
local mappings = {
|
||||
['['] = {
|
||||
m = 'Previous start of outer class',
|
||||
M = 'Previous end of outer class',
|
||||
['['] = 'Previous start of outer function',
|
||||
[']'] = 'Previous end of outer function'
|
||||
},
|
||||
[']'] = {
|
||||
m = 'Next start of outer class',
|
||||
M = 'Next end of outer class',
|
||||
['['] = 'Next start of outer function',
|
||||
[']'] = 'Next end of outer function'
|
||||
},
|
||||
g = {
|
||||
n = {
|
||||
name = 'Treesitter',
|
||||
d = 'Goto definition',
|
||||
D = 'List definitions',
|
||||
i = 'Initialize selection',
|
||||
j = 'Goto previous usage',
|
||||
k = 'Goto next usage',
|
||||
o = 'List definitions TOC',
|
||||
r = 'Rename within scope'
|
||||
}
|
||||
}
|
||||
}
|
||||
local visual_mappings = {
|
||||
a = {
|
||||
c = 'Outer class',
|
||||
f = 'Outer function'
|
||||
},
|
||||
|
||||
i = {
|
||||
c = 'Inner class',
|
||||
f = 'Inner function'
|
||||
},
|
||||
|
||||
g = {
|
||||
n = {
|
||||
name = 'Treesitter',
|
||||
n = 'Increment node',
|
||||
s = 'Increment scope',
|
||||
m = 'Decrement node'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wk.register(mappings)
|
||||
wk.register(visual_mappings, {mode = 'v'})
|
||||
require('mappings').treesitter()
|
||||
end
|
||||
|
||||
-- function M.detect_conf()
|
||||
-- function M.detect_language()
|
||||
-- require('detect-language').setup()
|
||||
-- vim.api.nvim_command('autocmd BufNewFile * DetectLanguageBufEnable')
|
||||
-- end
|
||||
|
||||
function M.iswap_conf()
|
||||
-- function M.spellsitter()
|
||||
-- require('spellsitter').setup {
|
||||
-- -- Whether enabled, can be a list of filetypes, e.g. {'python', 'lua'}
|
||||
-- enable = true,
|
||||
-- -- Highlight to use for bad spellings
|
||||
-- hl = 'SpellBad',
|
||||
-- -- Spellchecker to use. values:
|
||||
-- -- * vimfn: built-in spell checker using vim.fn.spellbadword()
|
||||
-- -- * ffi: built-in spell checker using the FFI to access the
|
||||
-- -- internal spell_check() function
|
||||
-- spellchecker = 'vimfn',
|
||||
-- }
|
||||
-- end
|
||||
|
||||
function M.indent_blankline()
|
||||
require('indent_blankline').setup {
|
||||
char = '│',
|
||||
-- space_char_blankline = '·',
|
||||
show_first_indent_level = true,
|
||||
filetype_exclude = {
|
||||
'startify', 'dashboard', 'alpha', 'log', 'gitcommit', 'packer', 'vimwiki',
|
||||
'markdown', 'org', 'json', 'txt', 'help', 'NvimTree', 'git', 'TelescopePrompt',
|
||||
'undotree', 'dotooagenda', 'fugitive',
|
||||
'' -- for all buffers without a filetype
|
||||
},
|
||||
buftype_exclude = {'terminal', 'nofile'},
|
||||
show_trailing_blankline_indent = false,
|
||||
-- show_end_of_line = true,
|
||||
show_current_context = true,
|
||||
context_patterns = {
|
||||
'class', 'function', 'method', 'block', 'list_literal', 'selector', '^if',
|
||||
'^table', 'if_statement', 'while', 'for'
|
||||
},
|
||||
use_treesitter = true
|
||||
}
|
||||
|
||||
-- Refresh often, since it is lazy-loaded
|
||||
-- vim.api.nvim_command('autocmd CursorMoved * IndentBlanklineRefresh')
|
||||
end
|
||||
|
||||
function M.iswap()
|
||||
require('iswap').setup {
|
||||
-- The keys that will be used as a selection, in order
|
||||
-- ('asdfghjklqwertyuiopzxcvbnm' by default)
|
||||
|
@ -372,11 +292,11 @@ function M.iswap_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.matchup_conf()
|
||||
function M.matchup()
|
||||
vim.g.matchup_matchparen_offscreen = {method = 'popup'}
|
||||
end
|
||||
|
||||
function M.twilight_conf()
|
||||
function M.twilight()
|
||||
require('twilight').setup {
|
||||
dimming = {
|
||||
alpha = 0.25, -- amount of dimming
|
||||
|
@ -396,7 +316,7 @@ function M.twilight_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.zenmode_conf()
|
||||
function M.zenmode()
|
||||
require('zen-mode').setup {
|
||||
window = {
|
||||
options = {
|
||||
|
@ -419,7 +339,7 @@ function M.zenmode_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.betterescape_conf()
|
||||
function M.better_escape()
|
||||
require('better_escape').setup {
|
||||
mapping = {'jk', 'kj'},
|
||||
timeout = vim.opt.timeoutlen:get(),
|
||||
|
@ -428,27 +348,16 @@ function M.betterescape_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.hop_conf()
|
||||
function M.hop()
|
||||
require('hop').setup {keys = 'etovxqpdygfblzhckisuran'}
|
||||
end
|
||||
|
||||
function M.eft_conf()
|
||||
function M.eft()
|
||||
vim.g.eft_index_function = {all = function() return true end}
|
||||
|
||||
-- Mappings
|
||||
vim.api.nvim_set_keymap('n', 'f', '<Plug>(eft-f)', {silent = true})
|
||||
vim.api.nvim_set_keymap('x', 'f', '<Plug>(eft-f)', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', 'F', '<Plug>(eft-F)', {silent = true})
|
||||
vim.api.nvim_set_keymap('x', 'F', '<Plug>(eft-F)', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', 't', '<Plug>(eft-t)', {silent = true})
|
||||
vim.api.nvim_set_keymap('x', 't', '<Plug>(eft-t)', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', 'T', '<Plug>(eft-T)', {silent = true})
|
||||
vim.api.nvim_set_keymap('x', 'T', '<Plug>(eft-T)', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', ';', '<Plug>(eft-repeat)', {silent = true})
|
||||
vim.api.nvim_set_keymap('x', ';', '<Plug>(eft-repeat)', {silent = true})
|
||||
require('mappings').eft()
|
||||
end
|
||||
|
||||
function M.dial_conf()
|
||||
function M.dial()
|
||||
local dial = require('dial')
|
||||
|
||||
-- Custom augends
|
||||
|
@ -493,23 +402,17 @@ function M.dial_conf()
|
|||
'color#hex'
|
||||
}
|
||||
|
||||
-- Mappings
|
||||
vim.api.nvim_set_keymap('n', '<C-a>', '<Plug>(dial-increment)', {silent = true})
|
||||
vim.api.nvim_set_keymap('v', '<C-a>', '<Plug>(dial-increment)', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-x>', '<Plug>(dial-decrement)', {silent = true})
|
||||
vim.api.nvim_set_keymap('v', '<C-x>', '<Plug>(dial-decrement)', {silent = true})
|
||||
vim.api.nvim_set_keymap('v', 'g<C-a>', '<Plug>(dial-increment-additional)', {silent = true})
|
||||
vim.api.nvim_set_keymap('v', 'g<C-x>', '<Plug>(dial-decrement-additional)', {silent = true})
|
||||
require('mappings').dial()
|
||||
end
|
||||
|
||||
function M.table_conf()
|
||||
function M.table_mode()
|
||||
vim.g.table_mode_disable_mappings = 1
|
||||
vim.g.table_mode_disable_tableize_mappings = 1
|
||||
vim.g.table_mode_map_prefix = '<leader>et'
|
||||
vim.g.table_mode_toggle_map = ''
|
||||
end
|
||||
|
||||
function M.comment_conf()
|
||||
function M.comment()
|
||||
require('Comment').setup {
|
||||
padding = true, -- add a ' ' between comment and the line
|
||||
sticky = true, -- whether the cursor should stay at its position
|
||||
|
@ -534,22 +437,19 @@ function M.comment_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.range_conf()
|
||||
function M.range_highlight()
|
||||
require('range-highlight').setup()
|
||||
end
|
||||
|
||||
function M.neogen_conf()
|
||||
function M.neogen()
|
||||
require('neogen').setup {
|
||||
enabled = true,
|
||||
input_after_comment = true
|
||||
}
|
||||
|
||||
-- Mappings
|
||||
vim.api.nvim_set_keymap('n', '<leader>eg', ':lua require("neogen").generate()<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-e>', ':lua require("neogen").jump_next()<CR>', {noremap = true, silent = true})
|
||||
require('mappings').neogen()
|
||||
end
|
||||
|
||||
function M.project_conf()
|
||||
function M.project()
|
||||
require('project_nvim').setup {
|
||||
manual_mode = false,
|
||||
detection_methods = {'lsp', 'pattern'},
|
||||
|
@ -570,7 +470,7 @@ function M.project_conf()
|
|||
-- vim.api.nvim_command('autocmd BufEnter * lua set_window_project_dir()')
|
||||
end
|
||||
|
||||
function M.gitlinker_conf()
|
||||
function M.gitlinker()
|
||||
require('gitlinker').setup {
|
||||
opts = {
|
||||
remote = nil, -- force the use of a specific remote
|
||||
|
@ -590,8 +490,32 @@ function M.gitlinker_conf()
|
|||
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})
|
||||
require('mappings').gitlinker()
|
||||
end
|
||||
|
||||
function M.filetype()
|
||||
require('filetype').setup {
|
||||
overrides = {
|
||||
extensions = {
|
||||
md = 'markdown',
|
||||
mkd = 'markdown',
|
||||
toml = 'toml',
|
||||
rasi = 'css',
|
||||
vifm = 'vim',
|
||||
log = 'log',
|
||||
LO = 'log'
|
||||
},
|
||||
literal = {
|
||||
vifmrc = 'vim'
|
||||
},
|
||||
complex = {
|
||||
['*_log'] = 'log',
|
||||
['G*_LOG'] = 'log',
|
||||
['.*waybar/config'] = 'jsonc',
|
||||
['.*lf/lfrc'] = 'sh'
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
|
@ -0,0 +1,139 @@
|
|||
local M = {}
|
||||
local conf = require('modules.editor.config')
|
||||
|
||||
M['norcalli/nvim-colorizer.lua'] = {
|
||||
cmd = 'ColorizerToggle',
|
||||
config = conf.colorizer
|
||||
}
|
||||
-- M['RRethy/vim-illuminate'] = { -- TODO: check out treesitter support, otherwise use nvim-treesitter-refactor
|
||||
-- event = 'CursorHold',
|
||||
-- setup = conf.illuminate
|
||||
-- }
|
||||
M['Olical/conjure'] = { -- TODO: config, check out fennel-repl.nvim
|
||||
ft = {'clojure', 'fennel', 'scheme', 'hy', 'janet', 'racket'}
|
||||
}
|
||||
M['kristijanhusak/orgmode.nvim'] = { -- TODO: highlights, check out neorg
|
||||
ft = 'org',
|
||||
requires = {{
|
||||
'akinsho/org-bullets.nvim',
|
||||
after = 'orgmode.nvim',
|
||||
config = conf.org_bullets
|
||||
}},
|
||||
config = conf.orgmode
|
||||
}
|
||||
M['lukas-reineke/headlines.nvim'] = {
|
||||
ft = {'org', 'markdown'},
|
||||
config = conf.headlines
|
||||
}
|
||||
M['nvim-treesitter/nvim-treesitter'] = {
|
||||
run = ':TSUpdate',
|
||||
event = 'BufRead',
|
||||
config = conf.treesitter
|
||||
}
|
||||
M['nvim-treesitter/playground'] = {after = 'nvim-treesitter'}
|
||||
M['nvim-treesitter/nvim-treesitter-refactor'] = {after = 'nvim-treesitter'}
|
||||
M['nvim-treesitter/nvim-treesitter-textobjects'] = {after = 'nvim-treesitter'}
|
||||
M['p00f/nvim-ts-rainbow'] = {after = 'nvim-treesitter'}
|
||||
M['windwp/nvim-ts-autotag'] = {after = 'nvim-treesitter'}
|
||||
M['romgrk/nvim-treesitter-context'] = {after = 'nvim-treesitter'}
|
||||
M['JoosepAlviste/nvim-ts-context-commentstring'] = {after = 'nvim-treesitter'}
|
||||
-- M['spywhere/detect-language.nvim'] = {
|
||||
-- event = 'BufNewFile',
|
||||
-- config = conf.detect_language
|
||||
-- }
|
||||
-- M['lewis6991/spellsitter.nvim'] = {
|
||||
-- event = {'BufRead', 'BufNewFile'},
|
||||
-- config = conf.spellsitter
|
||||
-- }
|
||||
M['lukas-reineke/indent-blankline.nvim'] = {
|
||||
after = 'nvim-treesitter',
|
||||
config = conf.indent_blankline
|
||||
}
|
||||
M['mizlan/iswap.nvim'] = {
|
||||
cmd = {'ISwapWith', 'ISwap'},
|
||||
wants = 'nvim-treesitter',
|
||||
config = conf.iswap
|
||||
}
|
||||
M['andymass/vim-matchup'] = {
|
||||
after = 'nvim-treesitter',
|
||||
config = conf.matchup
|
||||
}
|
||||
M['machakann/vim-sandwich'] = {keys = 's'} -- TODO: check out surround.nvim
|
||||
M['folke/zen-mode.nvim'] = {
|
||||
cmd = 'ZenMode',
|
||||
wants = 'twilight.nvim',
|
||||
requires = {{
|
||||
'folke/twilight.nvim',
|
||||
cmd = {'Twilight', 'TwilightEnable'},
|
||||
config = conf.twilight,
|
||||
opt = true
|
||||
}},
|
||||
config = conf.zenmode
|
||||
}
|
||||
M['max397574/better-escape.nvim'] = {
|
||||
event = 'InsertCharPre',
|
||||
config = conf.better_escape
|
||||
}
|
||||
M['phaazon/hop.nvim'] = { -- TODO: check out lightspeed.nvim
|
||||
cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'},
|
||||
config = conf.hop
|
||||
}
|
||||
M['hrsh7th/vim-eft'] = {
|
||||
keys = {
|
||||
{'n', 'f'}, {'x', 'f'}, {'n', 'F'}, {'x', 'F'},
|
||||
{'n', 't'}, {'x', 't'}, {'n', 'T'}, {'x', 'T'},
|
||||
{'n', ';'}, {'x', ';'}
|
||||
},
|
||||
config = conf.eft
|
||||
}
|
||||
M['monaqa/dial.nvim'] = {
|
||||
keys = {
|
||||
{'n', '<C-a>'}, {'v', '<C-a>'}, {'v', 'g<C-a>'},
|
||||
{'n', '<C-x>'}, {'v', '<C-x>'}, {'v', 'g<C-x>'}
|
||||
},
|
||||
config = conf.dial
|
||||
}
|
||||
M['junegunn/vim-easy-align'] = {cmd = {'EasyAlign', 'LiveEasyAlign'}}
|
||||
M['dhruvasagar/vim-table-mode'] = {
|
||||
cmd = {'Tableize', 'TableModeToggle', 'TableModeRealign'},
|
||||
setup = conf.table_mode
|
||||
}
|
||||
M['numToStr/Comment.nvim'] = {
|
||||
keys = {'gc', 'gb'},
|
||||
wants = 'nvim-ts-context-commentstring',
|
||||
config = conf.comment
|
||||
}
|
||||
M['winston0410/range-highlight.nvim'] = {
|
||||
event = 'CmdlineEnter',
|
||||
wants = 'cmd-parser.nvim',
|
||||
requires = {{'winston0410/cmd-parser.nvim', opt = true}},
|
||||
config = conf.range_highlight
|
||||
}
|
||||
M['danymat/neogen'] = {
|
||||
keys = '<leader>eg',
|
||||
wants = 'nvim-treesitter',
|
||||
config = conf.neogen
|
||||
}
|
||||
M['gpanders/editorconfig.nvim'] = {
|
||||
event = {'BufRead', 'BufNewFile'}
|
||||
}
|
||||
M['eraserhd/parinfer-rust'] = { -- TODO: move to nvim-parinfer (lua)
|
||||
run = 'cargo build --release',
|
||||
ft = {'clojure', 'lisp', 'scheme', 'fennel', 'racket', 'hy', 'janet', 'carp', 'wast'}
|
||||
}
|
||||
M['ahmedkhalf/project.nvim'] = {
|
||||
event = 'BufEnter',
|
||||
config = conf.project
|
||||
}
|
||||
M['ruifm/gitlinker.nvim'] = {
|
||||
wants = 'plenary.nvim',
|
||||
keys = {'<leader>gy', '<leader>gY'},
|
||||
config = conf.gitlinker
|
||||
}
|
||||
M['jbyuki/venn.nvim'] = {cmd = 'VBox'}
|
||||
M['nathom/filetype.nvim'] = {
|
||||
event = {'BufRead', 'BufNewFile'},
|
||||
config = conf.filetype
|
||||
}
|
||||
|
||||
return M
|
|
@ -1,631 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
function M.signature_conf()
|
||||
require('lsp_signature').setup {
|
||||
bind = true, -- This is mandatory, otherwise border config doesn't work
|
||||
floating_window = true,
|
||||
fix_pos = true,
|
||||
hint_enable = false,
|
||||
hint_prefix = ' ',
|
||||
hint_scheme = 'String',
|
||||
hi_parameter = 'Visual',
|
||||
transpancy = 5,
|
||||
handler_opts = {border = 'single'},
|
||||
zindex = 50, -- set to 200 to make the float window on top of others
|
||||
toggle_key = '<C-k>'
|
||||
}
|
||||
end
|
||||
|
||||
function M.saga_conf()
|
||||
require('lspsaga').init_lsp_saga {
|
||||
debug = false,
|
||||
use_saga_diagnostic_sign = true,
|
||||
-- diagnostic sign
|
||||
error_sign = '',
|
||||
warn_sign = '',
|
||||
hint_sign = '',
|
||||
infor_sign = '',
|
||||
dianostic_header_icon = ' ',
|
||||
-- code action title icon
|
||||
code_action_icon = ' ',
|
||||
code_action_prompt = {
|
||||
enable = false,
|
||||
sign = true,
|
||||
sign_priority = 40,
|
||||
virtual_text = true
|
||||
},
|
||||
finder_definition_icon = ' ',
|
||||
finder_reference_icon = ' ',
|
||||
max_preview_lines = 10,
|
||||
finder_action_keys = {
|
||||
open = 'o',
|
||||
vsplit = 's',
|
||||
split = 'i',
|
||||
quit = 'q',
|
||||
scroll_down = '<C-f>',
|
||||
scroll_up = '<C-b>'
|
||||
},
|
||||
code_action_keys = {
|
||||
quit = 'q',
|
||||
exec = '<CR>'
|
||||
},
|
||||
rename_action_keys = {
|
||||
quit = '<C-c>',
|
||||
exec = '<CR>'
|
||||
},
|
||||
definition_preview_icon = ' ',
|
||||
border_style = 'single',
|
||||
rename_prompt_prefix = '',
|
||||
server_filetype_map = {}
|
||||
}
|
||||
end
|
||||
|
||||
function M.lsp_conf()
|
||||
local lspconf = require('lspconfig')
|
||||
local on_attach = require('util').lsp_on_attach
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
-- Add additional capabilities supported by nvim-cmp
|
||||
local completionItem = capabilities.textDocument.completion.completionItem
|
||||
completionItem.documentationFormat = {'markdown', 'plaintext'}
|
||||
completionItem.snippetSupport = true
|
||||
completionItem.preselectSupport = true
|
||||
completionItem.insertReplaceSupport = true
|
||||
completionItem.labelDetailsSupport = true
|
||||
completionItem.deprecatedSupport = true
|
||||
completionItem.commitCharactersSupport = true
|
||||
completionItem.tagSupport = {valueSet = {1}}
|
||||
completionItem.resolveSupport = {
|
||||
properties = {
|
||||
'documentation',
|
||||
'detail',
|
||||
'additionalTextEdits',
|
||||
}
|
||||
}
|
||||
|
||||
-- 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('LspDiagnosticsSignInformation', {text = ''})
|
||||
vim.fn.sign_define('LspDiagnosticsSignHint', {text = ''})
|
||||
|
||||
---------------------------
|
||||
-- Server configurations --
|
||||
---------------------------
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
|
||||
local servers_path = vim.fn.stdpath('data') .. '/lsp'
|
||||
|
||||
-- C/C++
|
||||
lspconf.clangd.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
filetypes = {'c', 'cpp'},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
completeUnimported = true,
|
||||
clangdFileStatus = true
|
||||
},
|
||||
cmd = {
|
||||
'clangd',
|
||||
'-j=2',
|
||||
'--background-index',
|
||||
'--clang-tidy',
|
||||
'--completion-style=detailed',
|
||||
'--pch-storage=memory',
|
||||
'--header-insertion=iwyu',
|
||||
'--header-insertion-decorators'
|
||||
}
|
||||
}
|
||||
|
||||
-- Lua
|
||||
local lua_lib_path = {}
|
||||
local lua_runtime_path = {}
|
||||
|
||||
-- lua_lib_path[vim.fn.expand('~/.luarocks/share/lua/5.3')] = true
|
||||
-- lua_lib_path[vim.fn.expand('/usr/share/lua/5.3')] = true
|
||||
lua_lib_path[os.getenv('VIMRUNTIME') .. '/lua'] = true
|
||||
-- local function add(lib)
|
||||
-- for _, p in pairs(vim.fn.expand(lib .. '/lua', false, true)) do
|
||||
-- p = vim.loop.fs_realpath(p)
|
||||
-- if p then lua_lib_path[p] = true end
|
||||
-- end
|
||||
-- end
|
||||
-- for _, site in pairs(vim.split(vim.opt.packpath:get(), ',')) do
|
||||
-- add(site .. '/pack/*/opt/*')
|
||||
-- add(site .. '/pack/*/start/*')
|
||||
-- end
|
||||
|
||||
table.insert(lua_runtime_path, 'lua/?.lua')
|
||||
table.insert(lua_runtime_path, 'lua/?/init.lua')
|
||||
-- table.insert(lua_runtime_path, '?.lua')
|
||||
-- table.insert(lua_runtime_path, '?/?.lua')
|
||||
-- table.insert(lua_runtime_path, '?/init.lua')
|
||||
|
||||
for lib, _ in pairs(lua_lib_path) do
|
||||
table.insert(lua_runtime_path, lib .. '/?.lua')
|
||||
table.insert(lua_runtime_path, lib .. '/?/init.lua')
|
||||
end
|
||||
|
||||
lspconf.sumneko_lua.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = {
|
||||
servers_path .. '/sumneko_lua/bin/Linux/lua-language-server',
|
||||
'-E', '-e', 'LANG=en',
|
||||
servers_path .. '/sumneko_lua/main.lua'
|
||||
},
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {globals = {'vim'}},
|
||||
runtime = {version = 'LuaJIT', path = lua_runtime_path},
|
||||
workspace = {
|
||||
library = lua_lib_path,
|
||||
maxPreload = 1000,
|
||||
preloadFileSize = 150
|
||||
},
|
||||
completion = {callSnippet = 'Replace'},
|
||||
hint = {enable = true},
|
||||
telemetry = {enable = false}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- Go
|
||||
lspconf.gopls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = {servers_path .. '/gopls/gopls', '--remote=auto'},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
completeUnimported = true
|
||||
}
|
||||
}
|
||||
|
||||
-- Yaml
|
||||
-- lspconf.yamlls.setup {
|
||||
-- on_attach = on_attach,
|
||||
-- capabilities = capabilities,
|
||||
-- cmd = {servers_path .. '/yamlls/node_modules/.bin/yaml-language-server', '--stdio'},
|
||||
-- settings = {
|
||||
-- redhat = {telemetry = {enabled = false}},
|
||||
-- yaml = {
|
||||
-- format = {
|
||||
-- bracketSpacing = true,
|
||||
-- printWidth = 80,
|
||||
-- -- proseWrap = 'always', -- default is 'preserve'
|
||||
-- -- singleQuote = true,
|
||||
-- -- editor.formatOnType = true
|
||||
-- },
|
||||
-- schemas = require('schemastore').json.schemas()
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
|
||||
-- Ansible
|
||||
lspconf.ansiblels.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = {'node', servers_path .. '/ansiblels/out/server/src/server.js', '--stdio'},
|
||||
settings = {
|
||||
ansible = {
|
||||
python = {interpreterPath = 'python3'},
|
||||
executionEnvironment = {enabled = false}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- Tailwind
|
||||
-- lspconf.tailwindcss.setup {
|
||||
-- on_attach = on_attach,
|
||||
-- capabilities = capabilities,
|
||||
-- cmd = {servers_path .. '/tailwindcss/node_modules/.bin/tailwindcss-language-server', '--stdio'},
|
||||
-- settings = {
|
||||
-- tailwindCSS = {
|
||||
-- emmetCompletions = true
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
|
||||
-- Emmet
|
||||
lspconf.emmet_ls.setup {
|
||||
cmd = {servers_path .. '/emmet_ls/node_modules/.bin/emmet-ls', '--stdio'},
|
||||
filetypes = {
|
||||
'html', 'xml', 'css', 'scss', 'sass',
|
||||
'javascript', 'javascriptreact'
|
||||
},
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- HTML
|
||||
lspconf.html.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-html-language-server', '--stdio'},
|
||||
}
|
||||
|
||||
-- Eslint
|
||||
lspconf.eslint.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-eslint-language-server', '--stdio'},
|
||||
filetypes = {'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'vue', 'svelte'},
|
||||
handlers = {
|
||||
['eslint/noConfig'] = function()
|
||||
vim.notify('Unable to parse ESLint config.', vim.log.levels.WARN)
|
||||
end
|
||||
},
|
||||
settings = {
|
||||
codeAction = {
|
||||
disableRuleComment = {
|
||||
enable = true,
|
||||
location = 'separateLine'
|
||||
},
|
||||
showDocumentation = {enable = true}
|
||||
},
|
||||
codeActionOnSave = {
|
||||
enable = false, -- run ':EslintFixAll' manually
|
||||
mode = 'all'
|
||||
},
|
||||
format = true,
|
||||
nodePath = '',
|
||||
onIgnoredFiles = 'off',
|
||||
packageManager = 'npm',
|
||||
quiet = false,
|
||||
rulesCustomizations = {},
|
||||
run = 'onType',
|
||||
useESLintClass = false,
|
||||
validate = 'on',
|
||||
workingDirectory = {mode = 'auto'}
|
||||
}
|
||||
}
|
||||
|
||||
-- JSON
|
||||
lspconf.jsonls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-json-language-server', '--stdio'},
|
||||
settings = {
|
||||
json = {
|
||||
-- Schema catalog: https://www.schemastore.org/api/json/catalog.json
|
||||
schemas = require('schemastore').json.schemas()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- Others
|
||||
local servers = {
|
||||
rust_analyzer = {'rust-analyzer'},
|
||||
sqls = {servers_path .. '/sqls/sqls'},
|
||||
cmake = {servers_path .. '/cmake/venv/bin/cmake-language-server'},
|
||||
-- bashls = {servers_path .. '/bashls/node_modules/.bin/bash-language-server', 'start'},
|
||||
-- dockerls = {servers_path .. '/dockerls/node_modules/.bin/docker-langserver', '--stdio'},
|
||||
cssls = {servers_path .. '/vscode/node_modules/.bin/vscode-css-language-server', '--stdio'},
|
||||
pyright = {servers_path .. '/pyright/node_modules/.bin/pyright-langserver', '--stdio'},
|
||||
-- vimls = {servers_path .. '/vimls/node_modules/.bin/vim-language-server', '--stdio'},
|
||||
tsserver = {servers_path .. '/tsserver/node_modules/.bin/typescript-language-server', '--stdio'}
|
||||
}
|
||||
for server, _ in pairs(servers) do
|
||||
lspconf[server].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = servers[server]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: installers for the rest
|
||||
-- TODO: ansible-lint
|
||||
function M.null_ls_conf()
|
||||
local null_ls = require('null-ls')
|
||||
local linters_path = vim.fn.stdpath('data') .. '/lint'
|
||||
|
||||
-- Register sources
|
||||
null_ls.config {
|
||||
sources = {
|
||||
-- Formatters --
|
||||
-- null_ls.builtins.formatting.black.with {
|
||||
-- command = linters_path .. '/black/venv/bin/black'
|
||||
-- },
|
||||
-- null_ls.builtins.formatting.codespell.with {
|
||||
-- command = linters_path .. '/codespell/venv/bin/codespell'
|
||||
-- },
|
||||
null_ls.builtins.formatting.clang_format.with {
|
||||
filetypes = {'c', 'cpp'}
|
||||
},
|
||||
null_ls.builtins.formatting.cmake_format.with {
|
||||
command = linters_path .. '/cmake_format/venv/bin/cmake-format'
|
||||
},
|
||||
-- null_ls.builtins.formatting.fish_indent,
|
||||
-- null_ls.builtins.formatting.fixjson.with {command = 'fixjson'},
|
||||
-- null_ls.builtins.formatting.fnlfmt.with {command = 'fnlfmt'},
|
||||
-- null_ls.builtins.formatting.goimports.with {command = 'goimports'},
|
||||
-- null_ls.builtins.formatting.gofmt.with {command = 'gofmt'},
|
||||
-- null_ls.builtins.formatting.isort.with {
|
||||
-- command = linters_path .. '/isort/venv/bin/isort'
|
||||
-- },
|
||||
-- null_ls.builtins.formatting.nixfmt.with {command = 'nixfmt'},
|
||||
-- null_ls.builtins.formatting.prettier.with {
|
||||
-- command = linters_path .. '/prettier/node_modules/.bin/prettier'
|
||||
-- },
|
||||
-- null_ls.builtins.formatting.rustfmt.with {command = 'rustfmt'},
|
||||
-- null_ls.builtins.formatting.rustywind.with {command = 'rustywind'},
|
||||
-- null_ls.builtins.formatting.shfmt.with {
|
||||
-- command = linters_path .. '/shfmt/shfmt'
|
||||
-- },
|
||||
null_ls.builtins.formatting.stylua.with {
|
||||
condition = function(utils)
|
||||
return utils.root_has_file('stylua.toml')
|
||||
end,
|
||||
command = 'stylua'
|
||||
},
|
||||
-- null_ls.builtins.formatting.uncrustify.with {command = 'uncrustify'},
|
||||
-- null_ls.builtins.formatting.yapf.with {
|
||||
-- command = linters_path .. '/yapf/venv/bin/yapf'
|
||||
-- },
|
||||
-- null_ls.builtins.formatting.autopep8.with {
|
||||
-- command = linters_path .. '/autopep8/venv/bin/autopep8'
|
||||
-- },
|
||||
-- null_ls.builtins.formatting.stylelint.with {
|
||||
-- command = linters_path .. '/stylelint/node_modules/.bin/stylelint'
|
||||
-- },
|
||||
|
||||
-- Linters --
|
||||
null_ls.builtins.diagnostics.shellcheck,
|
||||
null_ls.builtins.diagnostics.codespell.with {
|
||||
command = linters_path .. '/codespell/venv/bin/codespell'
|
||||
},
|
||||
null_ls.builtins.diagnostics.cspell.with {
|
||||
command = linters_path .. '/cspell/node_modules/.bin/cspell'
|
||||
},
|
||||
-- null_ls.builtins.diagnostics.flake8.with {
|
||||
-- command = linters_path .. '/flake8/venv/bin/flake8'
|
||||
-- },
|
||||
null_ls.builtins.diagnostics.hadolint.with {
|
||||
command = vim.fn.stdpath('config') .. '/scripts/hadolint',
|
||||
args = {'$FILENAME'}
|
||||
},
|
||||
-- null_ls.builtins.diagnostics.luacheck,
|
||||
null_ls.builtins.diagnostics.cppcheck,
|
||||
null_ls.builtins.diagnostics.write_good.with {
|
||||
command = linters_path .. '/write_good/node_modules/.bin/write-good'
|
||||
},
|
||||
null_ls.builtins.diagnostics.markdownlint.with {
|
||||
command = linters_path .. '/markdownlint/node_modules/.bin/markdownlint'
|
||||
},
|
||||
-- null_ls.builtins.diagnostics.pylint.with {
|
||||
-- command = linters_path .. '/pylint/venv/bin/pylint'
|
||||
-- },
|
||||
null_ls.builtins.diagnostics.qmllint,
|
||||
null_ls.builtins.diagnostics.selene.with {
|
||||
condition = function(utils)
|
||||
return utils.root_has_file('selene.toml')
|
||||
end,
|
||||
},
|
||||
-- null_ls.builtins.diagnostics.vale.with {
|
||||
-- command = linters_path .. '/vale/vale'
|
||||
-- },
|
||||
-- null_ls.builtins.diagnostics.vint.with {
|
||||
-- command = linters_path .. '/vint/venv/bin/vint'
|
||||
-- },
|
||||
-- null_ls.builtins.diagnostics.stylelint.with {
|
||||
-- command = linters_path .. '/stylelint/node_modules/.bin/stylelint'
|
||||
-- },
|
||||
|
||||
-- Special --
|
||||
null_ls.builtins.hover.dictionary -- get word definition from dictionaryapi.dev
|
||||
}
|
||||
}
|
||||
|
||||
local lspconf = require('lspconfig')
|
||||
local on_attach = require('util').lsp_on_attach
|
||||
lspconf['null-ls'].setup {
|
||||
on_attach = on_attach
|
||||
}
|
||||
end
|
||||
|
||||
function M.sqls_conf()
|
||||
require('sqls').setup {
|
||||
picker = 'telescope'
|
||||
}
|
||||
end
|
||||
|
||||
function M.trouble_conf()
|
||||
require('trouble').setup {
|
||||
mode = 'lsp_workspace_diagnostics',
|
||||
fold_open = ' ',
|
||||
fold_closed = '',
|
||||
action_keys = {
|
||||
open_split = {'<c-h>'},
|
||||
open_vsplit = {'<c-v>'},
|
||||
open_tab = {'<c-t>'}
|
||||
},
|
||||
signs = {
|
||||
error = '',
|
||||
warning = '',
|
||||
information = '',
|
||||
hint = '',
|
||||
other = ''
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function M.comments_conf()
|
||||
require('todo-comments').setup {
|
||||
signs = false,
|
||||
-- sign_priority = 8,
|
||||
keywords = {
|
||||
FIX = {
|
||||
icon = ' ', -- icon used for the sign, and in search results
|
||||
color = 'error', -- can be a hex color, or a named color (see below)
|
||||
alt = {'FIXME', 'BUG', 'FIXIT', 'ISSUE'}, -- a set of other keywords that all map to this FIX keywords
|
||||
-- signs = false, -- configure signs for some keywords individually
|
||||
},
|
||||
TODO = {icon = ' ', color = 'info'},
|
||||
HACK = {icon = ' ', color = 'warning'},
|
||||
WARN = {icon = ' ', color = 'warning', alt = {'WARNING', 'XXX'}},
|
||||
PERF = {icon = ' ', alt = {'OPTIM', 'PERFORMANCE', 'OPTIMIZE'}},
|
||||
NOTE = {icon = ' ', color = 'hint', alt = {'INFO'}},
|
||||
},
|
||||
merge_keywords = true,
|
||||
highlight = {
|
||||
before = '', -- 'fg' or 'bg' or empty
|
||||
keyword = 'fg', -- 'fg', 'bg', 'wide' or empty. (wide is the same as bg, but will also highlight surrounding characters)
|
||||
after = '', -- 'fg' or 'bg' or empty
|
||||
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlightng (vim regex)
|
||||
comments_only = true, -- uses treesitter to match keywords in comments only
|
||||
max_line_len = 400, -- ignore lines longer than this
|
||||
exclude = {'org'} -- list of file types to exclude highlighting
|
||||
},
|
||||
colors = {
|
||||
error = {'LspDiagnosticsDefaultError', 'TSDanger', '#bf616a', '#e06c75'},
|
||||
warning = {'LspDiagnosticsDefaultWarning', 'TSWarning', '#ebcb8b', '#e5c07b'},
|
||||
info = {'LspDiagnosticsDefaultInformation', 'TSNote', '#81a1c1', '#61afef'},
|
||||
hint = {'LspDiagnosticsDefaultHint', '#88c0d0', '#56b6c2'},
|
||||
default = {'Normal', '#d8dee9', '#abb2bf'}
|
||||
},
|
||||
search = {
|
||||
command = 'rg',
|
||||
args = {
|
||||
'--hidden',
|
||||
'--color=never',
|
||||
'--no-heading',
|
||||
'--with-filename',
|
||||
'--line-number',
|
||||
'--column',
|
||||
},
|
||||
-- regex that will be used to match keywords.
|
||||
-- don't replace the (KEYWORDS) placeholder
|
||||
pattern = [[\b(KEYWORDS):]] -- ripgrep regex
|
||||
-- pattern = [[\b(KEYWORDS)\b]] -- match without the extra colon. You'll likely get false positives
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function M.outline_conf()
|
||||
vim.g.symbols_outline = {
|
||||
highlight_hovered_item = false,
|
||||
show_guides = true,
|
||||
auto_preview = true,
|
||||
position = 'right',
|
||||
width = 30,
|
||||
show_numbers = false,
|
||||
show_relative_numbers = false,
|
||||
show_symbol_details = true,
|
||||
preview_bg_highlight = 'NormalFloat',
|
||||
keymaps = { -- Can be string or a table
|
||||
close = {'<Esc>', 'q'},
|
||||
goto_location = '<Cr>',
|
||||
focus_location = 'o',
|
||||
hover_symbol = '<C-space>',
|
||||
toggle_preview = 'K',
|
||||
rename_symbol = 'r',
|
||||
code_actions = 'a',
|
||||
},
|
||||
lsp_blacklist = {},
|
||||
symbol_blacklist = {},
|
||||
symbols = {
|
||||
File = {icon = '', hl = 'TSURI'},
|
||||
Module = {icon = '', hl = 'TSNamespace'},
|
||||
Namespace = {icon = '', hl = 'TSNamespace'},
|
||||
Package = {icon = '', hl = 'TSNamespace'},
|
||||
Class = {icon = '𝓒', hl = 'TSType'},
|
||||
Method = {icon = 'ƒ', hl = 'TSMethod'},
|
||||
Property = {icon = '', hl = 'TSMethod'},
|
||||
Field = {icon = '', hl = 'TSField'},
|
||||
Constructor = {icon = '', hl = 'TSConstructor'},
|
||||
Enum = {icon = 'ℰ', hl = 'TSType'},
|
||||
Interface = {icon = 'ﰮ', hl = 'TSType'},
|
||||
Function = {icon = '', hl = 'TSFunction'},
|
||||
Variable = {icon = '', hl = 'TSConstant'},
|
||||
Constant = {icon = '', hl = 'TSConstant'},
|
||||
String = {icon = '𝓐', hl = 'TSString'},
|
||||
Number = {icon = '#', hl = 'TSNumber'},
|
||||
Boolean = {icon = '⊨', hl = 'TSBoolean'},
|
||||
Array = {icon = '', hl = 'TSConstant'},
|
||||
Object = {icon = '⦿', hl = 'TSType'},
|
||||
Key = {icon = '🔐', hl = 'TSType'},
|
||||
Null = {icon = 'NULL', hl = 'TSType'},
|
||||
EnumMember = {icon = '', hl = 'TSField'},
|
||||
Struct = {icon = '𝓢', hl = 'TSType'},
|
||||
Event = {icon = '🗲', hl = 'TSType'},
|
||||
Operator = {icon = '+', hl = 'TSOperator'},
|
||||
TypeParameter = {icon = '𝙏', hl = 'TSParameter'}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function M.dap_conf()
|
||||
local dap = require('dap')
|
||||
vim.fn.sign_define('DapBreakpoint', {text='', texthl='DapSignDefault'})
|
||||
vim.fn.sign_define('DapLogPoint', {text='', texthl='DapSignDefault'})
|
||||
vim.fn.sign_define('DapStopped', {text='ﱢ', texthl='DapSignDefault'})
|
||||
vim.fn.sign_define('DapBreakpointRejected', {text='', texthl='DapSignRejected'})
|
||||
|
||||
-- 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.
|
||||
border = 'single',
|
||||
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
|
|
@ -0,0 +1,258 @@
|
|||
local M = {}
|
||||
|
||||
function M.signature()
|
||||
require('lsp_signature').setup {
|
||||
bind = true, -- This is mandatory, otherwise border config doesn't work
|
||||
floating_window = true,
|
||||
fix_pos = true,
|
||||
hint_enable = false,
|
||||
hint_prefix = ' ',
|
||||
hint_scheme = 'String',
|
||||
hi_parameter = 'Visual',
|
||||
transparency = 5,
|
||||
handler_opts = {border = 'single'},
|
||||
zindex = 50, -- set to 200 to make the float window on top of others
|
||||
toggle_key = '<C-k>'
|
||||
}
|
||||
end
|
||||
|
||||
function M.saga()
|
||||
require('lspsaga').init_lsp_saga {
|
||||
debug = false,
|
||||
use_saga_diagnostic_sign = true,
|
||||
-- diagnostic sign
|
||||
error_sign = '',
|
||||
warn_sign = '',
|
||||
hint_sign = '',
|
||||
infor_sign = '',
|
||||
dianostic_header_icon = ' ',
|
||||
-- code action title icon
|
||||
code_action_icon = ' ',
|
||||
code_action_prompt = {
|
||||
enable = false,
|
||||
sign = true,
|
||||
sign_priority = 40,
|
||||
virtual_text = true
|
||||
},
|
||||
finder_definition_icon = ' ',
|
||||
finder_reference_icon = ' ',
|
||||
max_preview_lines = 10,
|
||||
finder_action_keys = {
|
||||
open = 'o',
|
||||
vsplit = 's',
|
||||
split = 'i',
|
||||
quit = 'q',
|
||||
scroll_down = '<C-f>',
|
||||
scroll_up = '<C-b>'
|
||||
},
|
||||
code_action_keys = {
|
||||
quit = 'q',
|
||||
exec = '<CR>'
|
||||
},
|
||||
rename_action_keys = {
|
||||
quit = '<C-c>',
|
||||
exec = '<CR>'
|
||||
},
|
||||
definition_preview_icon = ' ',
|
||||
border_style = 'single',
|
||||
rename_prompt_prefix = '',
|
||||
server_filetype_map = {}
|
||||
}
|
||||
end
|
||||
|
||||
function M.lsp()
|
||||
require('modules.lsp.lsp_conf')
|
||||
end
|
||||
|
||||
function M.null_ls()
|
||||
require('modules.lsp.null_ls_conf')
|
||||
end
|
||||
|
||||
function M.sqls()
|
||||
require('sqls').setup {
|
||||
picker = 'telescope'
|
||||
}
|
||||
end
|
||||
|
||||
function M.trouble()
|
||||
require('trouble').setup {
|
||||
mode = 'lsp_workspace_diagnostics',
|
||||
fold_open = ' ',
|
||||
fold_closed = '',
|
||||
action_keys = {
|
||||
open_split = {'<c-h>'},
|
||||
open_vsplit = {'<c-v>'},
|
||||
open_tab = {'<c-t>'}
|
||||
},
|
||||
signs = {
|
||||
error = '',
|
||||
warning = '',
|
||||
information = '',
|
||||
hint = '',
|
||||
other = ''
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function M.todo_comments()
|
||||
require('todo-comments').setup {
|
||||
signs = false,
|
||||
-- sign_priority = 8,
|
||||
keywords = {
|
||||
FIX = {
|
||||
icon = ' ', -- icon used for the sign, and in search results
|
||||
color = 'error', -- can be a hex color, or a named color (see below)
|
||||
alt = {'FIXME', 'BUG', 'FIXIT', 'ISSUE'}, -- a set of other keywords that all map to this FIX keywords
|
||||
-- signs = false, -- configure signs for some keywords individually
|
||||
},
|
||||
TODO = {icon = ' ', color = 'info'},
|
||||
HACK = {icon = ' ', color = 'warning'},
|
||||
WARN = {icon = ' ', color = 'warning', alt = {'WARNING', 'XXX'}},
|
||||
PERF = {icon = ' ', alt = {'OPTIM', 'PERFORMANCE', 'OPTIMIZE'}},
|
||||
NOTE = {icon = ' ', color = 'hint', alt = {'INFO'}},
|
||||
},
|
||||
merge_keywords = true,
|
||||
highlight = {
|
||||
before = '', -- 'fg' or 'bg' or empty
|
||||
keyword = 'fg', -- 'fg', 'bg', 'wide' or empty. (wide is the same as bg, but will also highlight surrounding characters)
|
||||
after = '', -- 'fg' or 'bg' or empty
|
||||
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlightng (vim regex)
|
||||
comments_only = true, -- uses treesitter to match keywords in comments only
|
||||
max_line_len = 400, -- ignore lines longer than this
|
||||
exclude = {'org'} -- list of file types to exclude highlighting
|
||||
},
|
||||
colors = {
|
||||
error = {'LspDiagnosticsDefaultError', 'TSDanger', '#bf616a', '#e06c75'},
|
||||
warning = {'LspDiagnosticsDefaultWarning', 'TSWarning', '#ebcb8b', '#e5c07b'},
|
||||
info = {'LspDiagnosticsDefaultInformation', 'TSNote', '#81a1c1', '#61afef'},
|
||||
hint = {'LspDiagnosticsDefaultHint', '#88c0d0', '#56b6c2'},
|
||||
default = {'Normal', '#d8dee9', '#abb2bf'}
|
||||
},
|
||||
search = {
|
||||
command = 'rg',
|
||||
args = {
|
||||
'--hidden',
|
||||
'--color=never',
|
||||
'--no-heading',
|
||||
'--with-filename',
|
||||
'--line-number',
|
||||
'--column',
|
||||
},
|
||||
-- regex that will be used to match keywords.
|
||||
-- don't replace the (KEYWORDS) placeholder
|
||||
pattern = [[\b(KEYWORDS):]] -- ripgrep regex
|
||||
-- pattern = [[\b(KEYWORDS)\b]] -- match without the extra colon. You'll likely get false positives
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function M.symbols_outline()
|
||||
vim.g.symbols_outline = {
|
||||
highlight_hovered_item = false,
|
||||
show_guides = true,
|
||||
auto_preview = true,
|
||||
position = 'right',
|
||||
width = 30,
|
||||
show_numbers = false,
|
||||
show_relative_numbers = false,
|
||||
show_symbol_details = true,
|
||||
preview_bg_highlight = 'NormalFloat',
|
||||
keymaps = { -- Can be string or a table
|
||||
close = {'<Esc>', 'q'},
|
||||
goto_location = '<Cr>',
|
||||
focus_location = 'o',
|
||||
hover_symbol = '<C-space>',
|
||||
toggle_preview = 'K',
|
||||
rename_symbol = 'r',
|
||||
code_actions = 'a',
|
||||
},
|
||||
lsp_blacklist = {},
|
||||
symbol_blacklist = {},
|
||||
symbols = {
|
||||
File = {icon = '', hl = 'TSURI'},
|
||||
Module = {icon = '', hl = 'TSNamespace'},
|
||||
Namespace = {icon = '', hl = 'TSNamespace'},
|
||||
Package = {icon = '', hl = 'TSNamespace'},
|
||||
Class = {icon = '𝓒', hl = 'TSType'},
|
||||
Method = {icon = 'ƒ', hl = 'TSMethod'},
|
||||
Property = {icon = '', hl = 'TSMethod'},
|
||||
Field = {icon = '', hl = 'TSField'},
|
||||
Constructor = {icon = '', hl = 'TSConstructor'},
|
||||
Enum = {icon = 'ℰ', hl = 'TSType'},
|
||||
Interface = {icon = 'ﰮ', hl = 'TSType'},
|
||||
Function = {icon = '', hl = 'TSFunction'},
|
||||
Variable = {icon = '', hl = 'TSConstant'},
|
||||
Constant = {icon = '', hl = 'TSConstant'},
|
||||
String = {icon = '𝓐', hl = 'TSString'},
|
||||
Number = {icon = '#', hl = 'TSNumber'},
|
||||
Boolean = {icon = '⊨', hl = 'TSBoolean'},
|
||||
Array = {icon = '', hl = 'TSConstant'},
|
||||
Object = {icon = '⦿', hl = 'TSType'},
|
||||
Key = {icon = '🔐', hl = 'TSType'},
|
||||
Null = {icon = 'NULL', hl = 'TSType'},
|
||||
EnumMember = {icon = '', hl = 'TSField'},
|
||||
Struct = {icon = '𝓢', hl = 'TSType'},
|
||||
Event = {icon = '🗲', hl = 'TSType'},
|
||||
Operator = {icon = '+', hl = 'TSOperator'},
|
||||
TypeParameter = {icon = '𝙏', hl = 'TSParameter'}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function M.dap()
|
||||
local dap = require('dap')
|
||||
vim.fn.sign_define('DapBreakpoint', {text='', texthl='DapSignDefault'})
|
||||
vim.fn.sign_define('DapLogPoint', {text='', texthl='DapSignDefault'})
|
||||
vim.fn.sign_define('DapStopped', {text='ﱢ', texthl='DapSignDefault'})
|
||||
vim.fn.sign_define('DapBreakpointRejected', {text='', texthl='DapSignRejected'})
|
||||
|
||||
require('mappings').dap()
|
||||
end
|
||||
|
||||
function M.dapui()
|
||||
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.
|
||||
border = 'single',
|
||||
mappings = {
|
||||
close = {'q', '<Esc>'}
|
||||
}
|
||||
},
|
||||
windows = {indent = 1}
|
||||
}
|
||||
|
||||
require('mappings').dapui()
|
||||
end
|
||||
|
||||
return M
|
|
@ -0,0 +1,240 @@
|
|||
local servers_path = vim.fn.stdpath('data') .. '/lsp'
|
||||
local lspconf = require('lspconfig')
|
||||
local util = require('modules.lsp.util')
|
||||
local on_attach = util.common_on_attach
|
||||
local capabilities = util.common_capabilities()
|
||||
|
||||
util.setup_handlers()
|
||||
|
||||
lspconf.clangd.setup {
|
||||
filetypes = {'c', 'cpp'},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
completeUnimported = true,
|
||||
clangdFileStatus = true
|
||||
},
|
||||
cmd = {
|
||||
'clangd',
|
||||
'-j=2',
|
||||
'--background-index',
|
||||
'--clang-tidy',
|
||||
'--completion-style=detailed',
|
||||
'--pch-storage=memory',
|
||||
'--header-insertion=iwyu',
|
||||
'--header-insertion-decorators'
|
||||
},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
lspconf.sumneko_lua.setup {
|
||||
cmd = {
|
||||
servers_path .. '/sumneko_lua/bin/Linux/lua-language-server',
|
||||
'-E', '-e', 'LANG=en',
|
||||
servers_path .. '/sumneko_lua/main.lua'
|
||||
},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {globals = {'vim'}},
|
||||
runtime = {version = 'LuaJIT', path = util.lua_runtime_path()},
|
||||
workspace = {
|
||||
library = util.lua_lib_path(),
|
||||
maxPreload = 1000,
|
||||
preloadFileSize = 150
|
||||
},
|
||||
completion = {callSnippet = 'Replace'},
|
||||
hint = {enable = true},
|
||||
telemetry = {enable = false}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lspconf.pylsp.setup {
|
||||
cmd = {vim.fn.stdpath('config') .. '/scripts/pylsp'},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
pylsp = {
|
||||
-- configurationSources = {'pycodestyle', 'flake8'},
|
||||
plugins = {
|
||||
-- flake8 = {
|
||||
-- enabled = true,
|
||||
-- executable = servers_path .. 'pylsp/venv/bin/flake8'
|
||||
-- },
|
||||
mccabe = {
|
||||
enabled = true,
|
||||
threshold = 15
|
||||
},
|
||||
pycodestyle = {enabled = true},
|
||||
-- pydocstyle = {enabled = true},
|
||||
pyflakes = {enabled = true},
|
||||
-- pylint = {
|
||||
-- enabled = true,
|
||||
-- executable = servers_path .. 'pylsp/venv/bin/pylint'
|
||||
-- },
|
||||
rope_completion = {
|
||||
enabled = true,
|
||||
eager = false
|
||||
},
|
||||
yapf = {enabled = true}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lspconf.gopls.setup {
|
||||
cmd = {servers_path .. '/gopls/gopls', '--remote=auto'},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
completeUnimported = true
|
||||
}
|
||||
}
|
||||
|
||||
-- lspconf.yamlls.setup {
|
||||
-- cmd = {servers_path .. '/yamlls/node_modules/.bin/yaml-language-server', '--stdio'},
|
||||
-- on_attach = on_attach,
|
||||
-- capabilities = capabilities,
|
||||
-- settings = {
|
||||
-- redhat = {telemetry = {enabled = false}},
|
||||
-- yaml = {
|
||||
-- format = {
|
||||
-- bracketSpacing = true,
|
||||
-- printWidth = 80,
|
||||
-- -- proseWrap = 'always', -- default is 'preserve'
|
||||
-- -- singleQuote = true,
|
||||
-- -- editor.formatOnType = true
|
||||
-- },
|
||||
-- schemas = require('schemastore').json.schemas()
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
|
||||
lspconf.ansiblels.setup {
|
||||
cmd = {'node', servers_path .. '/ansiblels/out/server/src/server.js', '--stdio'},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
ansible = {
|
||||
python = {interpreterPath = 'python3'},
|
||||
executionEnvironment = {enabled = false}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- lspconf.tailwindcss.setup {
|
||||
-- cmd = {servers_path .. '/tailwindcss/node_modules/.bin/tailwindcss-language-server', '--stdio'},
|
||||
-- on_attach = on_attach,
|
||||
-- capabilities = capabilities,
|
||||
-- settings = {
|
||||
-- tailwindCSS = {
|
||||
-- emmetCompletions = true
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
|
||||
lspconf.emmet_ls.setup {
|
||||
cmd = {servers_path .. '/emmet_ls/node_modules/.bin/emmet-ls', '--stdio'},
|
||||
capabilities = capabilities,
|
||||
filetypes = {
|
||||
'html', 'xml', 'css', 'scss', 'sass',
|
||||
'javascript', 'javascriptreact'
|
||||
},
|
||||
}
|
||||
|
||||
lspconf.eslint.setup {
|
||||
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-eslint-language-server', '--stdio'},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
filetypes = {'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'vue', 'svelte'},
|
||||
handlers = {
|
||||
['eslint/noConfig'] = function()
|
||||
vim.notify('Unable to parse ESLint config.', vim.log.levels.WARN)
|
||||
end
|
||||
},
|
||||
settings = {
|
||||
codeAction = {
|
||||
disableRuleComment = {
|
||||
enable = true,
|
||||
location = 'separateLine'
|
||||
},
|
||||
showDocumentation = {enable = true}
|
||||
},
|
||||
codeActionOnSave = {
|
||||
enable = false, -- run ':EslintFixAll' manually
|
||||
mode = 'all'
|
||||
},
|
||||
format = true,
|
||||
nodePath = '',
|
||||
onIgnoredFiles = 'off',
|
||||
packageManager = 'npm',
|
||||
quiet = false,
|
||||
rulesCustomizations = {},
|
||||
run = 'onType',
|
||||
useESLintClass = false,
|
||||
validate = 'on',
|
||||
workingDirectory = {mode = 'auto'}
|
||||
}
|
||||
}
|
||||
|
||||
lspconf.jsonls.setup {
|
||||
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-json-language-server', '--stdio'},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
json = {
|
||||
-- Schema catalog: https://www.schemastore.org/api/json/catalog.json
|
||||
schemas = require('schemastore').json.schemas()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lspconf.rust_analyzer.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
['rust-analyzer'] = {
|
||||
checkOnSave = {
|
||||
enable = true,
|
||||
command = 'clippy'
|
||||
},
|
||||
callInfo = {full = true},
|
||||
lens = {
|
||||
enable = true,
|
||||
references = true,
|
||||
implementations = true,
|
||||
enumVariantReferences = true,
|
||||
methodReferences = true
|
||||
},
|
||||
inlayHints = {
|
||||
enable = true,
|
||||
typeHints = true,
|
||||
parameterHints = true
|
||||
},
|
||||
hoverActions = {enable = true},
|
||||
cargo = {autoreload = true}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local servers = {
|
||||
sqls = {servers_path .. '/sqls/sqls'},
|
||||
cmake = {servers_path .. '/cmake/venv/bin/cmake-language-server'},
|
||||
-- bashls = {servers_path .. '/bashls/node_modules/.bin/bash-language-server', 'start'},
|
||||
-- dockerls = {servers_path .. '/dockerls/node_modules/.bin/docker-langserver', '--stdio'},
|
||||
html = {servers_path .. '/vscode/node_modules/.bin/vscode-html-language-server', '--stdio'},
|
||||
cssls = {servers_path .. '/vscode/node_modules/.bin/vscode-css-language-server', '--stdio'},
|
||||
-- vimls = {servers_path .. '/vimls/node_modules/.bin/vim-language-server', '--stdio'},
|
||||
tsserver = {servers_path .. '/tsserver/node_modules/.bin/typescript-language-server', '--stdio'}
|
||||
}
|
||||
|
||||
for server, _ in pairs(servers) do
|
||||
lspconf[server].setup {
|
||||
cmd = servers[server],
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
end
|
|
@ -0,0 +1,81 @@
|
|||
-- TODO: installers for the rest
|
||||
local linters_path = vim.fn.stdpath('data') .. '/lint'
|
||||
local null_ls = require('null-ls')
|
||||
local lspconf = require('lspconfig')
|
||||
local on_attach = require('modules.lsp.util').common_on_attach
|
||||
|
||||
local sources = {
|
||||
-- null_ls.builtins.formatting.codespell.with {
|
||||
-- command = linters_path .. '/codespell/venv/bin/codespell'
|
||||
-- },
|
||||
null_ls.builtins.formatting.clang_format.with {
|
||||
filetypes = {'c', 'cpp'}
|
||||
},
|
||||
null_ls.builtins.formatting.cmake_format.with {
|
||||
command = linters_path .. '/cmake_format/venv/bin/cmake-format'
|
||||
},
|
||||
null_ls.builtins.formatting.fish_indent,
|
||||
-- null_ls.builtins.formatting.fixjson.with {command = 'fixjson'},
|
||||
-- null_ls.builtins.formatting.fnlfmt.with {command = 'fnlfmt'},
|
||||
-- null_ls.builtins.formatting.goimports.with {command = 'goimports'},
|
||||
-- null_ls.builtins.formatting.gofmt.with {command = 'gofmt'},
|
||||
-- null_ls.builtins.formatting.nixfmt.with {command = 'nixfmt'},
|
||||
-- null_ls.builtins.formatting.prettier.with {
|
||||
-- command = linters_path .. '/prettier/node_modules/.bin/prettier'
|
||||
-- },
|
||||
-- null_ls.builtins.formatting.rustfmt.with {command = 'rustfmt'},
|
||||
-- null_ls.builtins.formatting.rustywind.with {command = 'rustywind'},
|
||||
-- null_ls.builtins.formatting.shfmt.with {
|
||||
-- command = linters_path .. '/shfmt/shfmt'
|
||||
-- },
|
||||
null_ls.builtins.formatting.stylua.with {
|
||||
condition = function(utils)
|
||||
return utils.root_has_file('stylua.toml')
|
||||
end
|
||||
},
|
||||
-- null_ls.builtins.formatting.uncrustify.with {command = 'uncrustify'},
|
||||
-- null_ls.builtins.formatting.stylelint.with {
|
||||
-- command = linters_path .. '/stylelint/node_modules/.bin/stylelint'
|
||||
-- },
|
||||
null_ls.builtins.diagnostics.shellcheck,
|
||||
null_ls.builtins.diagnostics.codespell.with {
|
||||
command = linters_path .. '/codespell/venv/bin/codespell'
|
||||
},
|
||||
-- null_ls.builtins.diagnostics.cspell.with {
|
||||
-- command = linters_path .. '/cspell/node_modules/.bin/cspell',
|
||||
-- filetypes = {'tex', 'markdown', 'org'}
|
||||
-- },
|
||||
null_ls.builtins.diagnostics.hadolint.with {
|
||||
command = vim.fn.stdpath('config') .. '/scripts/hadolint',
|
||||
args = {'$FILENAME'}
|
||||
},
|
||||
-- null_ls.builtins.diagnostics.luacheck,
|
||||
null_ls.builtins.diagnostics.cppcheck,
|
||||
null_ls.builtins.diagnostics.write_good.with {
|
||||
command = linters_path .. '/write_good/node_modules/.bin/write-good'
|
||||
},
|
||||
null_ls.builtins.diagnostics.markdownlint.with {
|
||||
command = linters_path .. '/markdownlint/node_modules/.bin/markdownlint'
|
||||
},
|
||||
null_ls.builtins.diagnostics.qmllint,
|
||||
null_ls.builtins.diagnostics.selene.with {
|
||||
condition = function(utils)
|
||||
return utils.root_has_file('selene.toml')
|
||||
end
|
||||
},
|
||||
-- null_ls.builtins.diagnostics.vale.with {
|
||||
-- command = linters_path .. '/vale/vale'
|
||||
-- },
|
||||
null_ls.builtins.diagnostics.vint.with {
|
||||
command = linters_path .. '/vint/venv/bin/vint'
|
||||
},
|
||||
-- null_ls.builtins.diagnostics.stylelint.with {
|
||||
-- command = linters_path .. '/stylelint/node_modules/.bin/stylelint'
|
||||
-- },
|
||||
null_ls.builtins.hover.dictionary -- get word definition from dictionaryapi.dev
|
||||
}
|
||||
|
||||
null_ls.config {sources = sources}
|
||||
lspconf['null-ls'].setup {
|
||||
on_attach = on_attach
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
local M = {}
|
||||
local conf = require('modules.lsp.config')
|
||||
|
||||
M['neovim/nvim-lspconfig'] = {
|
||||
event = 'BufReadPre',
|
||||
wants = {'lsp_signature.nvim', 'lspsaga.nvim', 'SchemaStore.nvim'},
|
||||
requires = {
|
||||
{
|
||||
'ray-x/lsp_signature.nvim',
|
||||
config = conf.signature,
|
||||
opt = true
|
||||
},
|
||||
{
|
||||
'tami5/lspsaga.nvim',
|
||||
branch = 'nvim51',
|
||||
config = conf.saga,
|
||||
opt = true
|
||||
},
|
||||
{'b0o/SchemaStore.nvim', opt = true}
|
||||
},
|
||||
config = conf.lsp
|
||||
}
|
||||
M['jose-elias-alvarez/null-ls.nvim'] = {
|
||||
wants = 'plenary.nvim',
|
||||
after = 'nvim-lspconfig',
|
||||
config = conf.null_ls
|
||||
}
|
||||
M['nanotee/sqls.nvim'] = {
|
||||
ft = {'sql', 'mysql'},
|
||||
wants = 'nvim-lspconfig',
|
||||
config = conf.sqls
|
||||
}
|
||||
M['folke/trouble.nvim'] = {
|
||||
cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'},
|
||||
config = conf.trouble
|
||||
}
|
||||
M['folke/todo-comments.nvim'] = {
|
||||
wants = 'plenary.nvim',
|
||||
event = 'BufRead',
|
||||
config = conf.todo_comments
|
||||
}
|
||||
M['simrat39/symbols-outline.nvim'] = {
|
||||
cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'},
|
||||
setup = conf.symbols_outline
|
||||
}
|
||||
M['rcarriga/nvim-dap-ui'] = { -- TODO: config, scripts to install/update dap servers
|
||||
keys = '<leader>d',
|
||||
wants = 'nvim-dap',
|
||||
requires = {{
|
||||
'mfussenegger/nvim-dap',
|
||||
config = conf.dap,
|
||||
opt = true
|
||||
}},
|
||||
config = conf.dapui
|
||||
}
|
||||
|
||||
return M
|
|
@ -0,0 +1,218 @@
|
|||
local M = {}
|
||||
local wk = require('which-key')
|
||||
|
||||
local function setup_mappings(bufnr)
|
||||
local lsp_mappings = {
|
||||
g = {
|
||||
d = {':lua vim.lsp.buf.definition()<CR>', 'Goto definition'},
|
||||
D = {':lua vim.lsp.buf.declaration()<CR>', 'Goto declaration'},
|
||||
i = {':Lspsaga implement<CR>', 'Implementations'},
|
||||
I = {':Telescope lsp_implementations<CR>', 'Implementations (Telescope)'},
|
||||
r = {':TroubleToggle lsp_references<CR>', 'References'},
|
||||
R = {':Telescope lsp_references<CR>', 'References (Telescope)'}
|
||||
},
|
||||
K = {':Lspsaga hover_doc<CR>', 'Hover doc'},
|
||||
['[d'] = {':Lspsaga diagnostic_jump_prev<CR>', 'Previous diagnostics'},
|
||||
[']d'] = {':Lspsaga diagnostic_jump_next<CR>', 'Next diagnostics'}
|
||||
}
|
||||
local lsp_leader_mappings = {
|
||||
l = {
|
||||
name = 'LSP',
|
||||
a = {':lua vim.lsp.buf.add_workspace_folder()<CR>', 'Add workspace folder'},
|
||||
b = {':TroubleToggle lsp_document_diagnostics<CR>', 'Buffer diagnostics'},
|
||||
B = {':Telescope lsp_document_diagnostics<CR>', 'Buffer diagnostics (Telescope)'},
|
||||
c = {':Lspsaga code_action<CR>', 'Code action'},
|
||||
C = {':Telescope lsp_code_actions<CR>', 'Code action (Telescope)'},
|
||||
d = {':TroubleToggle lsp_definitions<CR>', 'Definitions'},
|
||||
D = {':Telescope lsp_definitions<CR>', 'Definitions (Telescope)'},
|
||||
e = {':Lspsaga show_line_diagnostics<CR>', 'Line diagnostics'},
|
||||
f = {':Lspsaga lsp_finder<CR>', 'Finder'},
|
||||
g = {':SymbolsOutline<CR>', 'Symbol outline'},
|
||||
i = {':LspInfo<CR>', 'Lsp info'},
|
||||
l = {':TroubleToggle loclist<CR>', 'Diagnostics loclist'},
|
||||
n = {':Lspsaga rename<CR>', 'Rename'},
|
||||
p = {':Lspsaga preview_definition<CR>', 'Preview definition'},
|
||||
r = {':lua vim.lsp.buf.remove_workspace_folder()<CR>', 'Remove workspace folder'},
|
||||
s = {':Telescope lsp_document_symbols<CR>', 'Buffer symbols'},
|
||||
S = {':Telescope lsp_workspace_symbols<CR>', 'Workspace symbols'},
|
||||
t = {':TroubleToggle<CR>', 'Toggle Trouble'},
|
||||
w = {':TroubleToggle lsp_workspace_diagnostics<CR>', 'Workspace diagnostics'},
|
||||
W = {':Telescope lsp_workspace_diagnostics<CR>', 'Workspace diagnostics (Telescope)'},
|
||||
x = {':lua vim.lsp.buf.signature_help()<CR>', 'Signature help'},
|
||||
y = {':lua vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders()), vim.log.levels.INFO)<CR>', 'List workspace folders'}
|
||||
}
|
||||
}
|
||||
local lsp_visual_mappings = {
|
||||
l = {
|
||||
name = 'LSP',
|
||||
c = {':<C-U>Lspsaga range_code_action<CR>', 'Range code action'},
|
||||
C = {':Telescope lsp_range_code_actions<CR>', 'Range code action (Telescope)'}
|
||||
}
|
||||
}
|
||||
|
||||
wk.register(lsp_mappings, {buffer = bufnr})
|
||||
wk.register(lsp_leader_mappings, {buffer = bufnr, prefix = '<leader>'})
|
||||
wk.register(lsp_visual_mappings, {buffer = bufnr, prefix = '<leader>', mode = 'v'})
|
||||
|
||||
local opts = {noremap = true, silent = true}
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-f>', ':lua require("lspsaga.action").smart_scroll_with_saga(1)<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-b>', ':lua require("lspsaga.action").smart_scroll_with_saga(-1)<CR>', opts)
|
||||
end
|
||||
|
||||
local function setup_formatting_mapping(client, bufnr)
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
wk.register({
|
||||
['lo'] = {':lua vim.lsp.buf.formatting()<CR>', 'Format buffer'}
|
||||
}, {buffer = bufnr, prefix = '<leader>'})
|
||||
-- vim.api.nvim_command('autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()')
|
||||
elseif client.resolved_capabilities.document_range_formatting then
|
||||
wk.register({
|
||||
['lo'] = {':lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})<CR>', 'Format buffer'}
|
||||
}, {buffer = bufnr, prefix = '<leader>'})
|
||||
wk.register({
|
||||
['lo'] = {':lua vim.lsp.buf.range_formatting()<CR>', 'Format range'}
|
||||
}, {buffer = bufnr, prefix = '<leader>', mode = 'v'})
|
||||
-- vim.api.nvim_command('autocmd BufWritePre <buffer> lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})')
|
||||
end
|
||||
end
|
||||
|
||||
local function setup_document_highlight(client)
|
||||
if client.resolved_capabilities.document_highlight then
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
augroup lsp_document_highlight
|
||||
autocmd! * <buffer>
|
||||
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||
augroup END
|
||||
]],
|
||||
false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function setup_codelens(client)
|
||||
if client.resolved_capabilities.code_lens then
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
augroup lsp_code_lens_refresh
|
||||
autocmd! * <buffer>
|
||||
autocmd InsertLeave <buffer> lua vim.lsp.codelens.refresh()
|
||||
autocmd InsertLeave <buffer> lua vim.lsp.codelens.display()
|
||||
augroup END
|
||||
]],
|
||||
false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function M.common_on_attach(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
setup_mappings(bufnr)
|
||||
setup_codelens(client)
|
||||
setup_document_highlight(client)
|
||||
setup_formatting_mapping(client, bufnr)
|
||||
end
|
||||
|
||||
function M.common_capabilities()
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
-- Add additional capabilities supported by nvim-cmp
|
||||
local completionItem = capabilities.textDocument.completion.completionItem
|
||||
completionItem.documentationFormat = {'markdown', 'plaintext'}
|
||||
completionItem.snippetSupport = true
|
||||
completionItem.preselectSupport = true
|
||||
completionItem.insertReplaceSupport = true
|
||||
completionItem.labelDetailsSupport = true
|
||||
completionItem.deprecatedSupport = true
|
||||
completionItem.commitCharactersSupport = true
|
||||
completionItem.tagSupport = {valueSet = {1}}
|
||||
completionItem.resolveSupport = {
|
||||
properties = {
|
||||
'documentation',
|
||||
'detail',
|
||||
'additionalTextEdits',
|
||||
}
|
||||
}
|
||||
|
||||
return capabilities
|
||||
end
|
||||
|
||||
function M.setup_handlers()
|
||||
local border = {
|
||||
{'┌', 'FloatBorder'},
|
||||
{'─', 'FloatBorder'},
|
||||
{'┐', 'FloatBorder'},
|
||||
{'│', 'FloatBorder'},
|
||||
{'┘', 'FloatBorder'},
|
||||
{'─', 'FloatBorder'},
|
||||
{'└', 'FloatBorder'},
|
||||
{'│', 'FloatBorder'}
|
||||
}
|
||||
|
||||
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
underline = false,
|
||||
virtual_text = {
|
||||
prefix = '■',
|
||||
source = 'always'
|
||||
},
|
||||
signs = {
|
||||
active = true,
|
||||
values = {
|
||||
{name = 'LspDiagnosticsSignError', text = ''},
|
||||
{name = 'LspDiagnosticsSignWarning', text = ''},
|
||||
{name = 'LspDiagnosticsSignInformation', text = ''},
|
||||
{name = 'LspDiagnosticsSignHint', text = ''}
|
||||
}
|
||||
},
|
||||
update_in_insert = false,
|
||||
severity_sort = true
|
||||
})
|
||||
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
border = border,
|
||||
})
|
||||
|
||||
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||
border = border,
|
||||
})
|
||||
end
|
||||
|
||||
function M.lua_lib_path()
|
||||
local lib_path = {}
|
||||
|
||||
-- lib_path[vim.fn.expand('~/.luarocks/share/lua/5.3')] = true
|
||||
-- lib_path[vim.fn.expand('/usr/share/lua/5.3')] = true
|
||||
lib_path[os.getenv('VIMRUNTIME') .. '/lua'] = true
|
||||
-- local function add(lib)
|
||||
-- for _, p in pairs(vim.fn.expand(lib .. '/lua', false, true)) do
|
||||
-- p = vim.loop.fs_realpath(p)
|
||||
-- if p then lib_path[p] = true end
|
||||
-- end
|
||||
-- end
|
||||
-- for _, site in pairs(vim.split(vim.opt.packpath:get(), ',')) do
|
||||
-- add(site .. '/pack/*/opt/*')
|
||||
-- add(site .. '/pack/*/start/*')
|
||||
-- end
|
||||
|
||||
return lib_path
|
||||
end
|
||||
|
||||
function M.lua_runtime_path()
|
||||
local lib_path = M.lua_lib_path()
|
||||
local runtime_path = {}
|
||||
|
||||
table.insert(runtime_path, 'lua/?.lua')
|
||||
table.insert(runtime_path, 'lua/?/init.lua')
|
||||
-- table.insert(runtime_path, '?.lua')
|
||||
-- table.insert(runtime_path, '?/?.lua')
|
||||
-- table.insert(runtime_path, '?/init.lua')
|
||||
|
||||
for lib, _ in pairs(lib_path) do
|
||||
table.insert(runtime_path, lib .. '/?.lua')
|
||||
table.insert(runtime_path, lib .. '/?/init.lua')
|
||||
end
|
||||
|
||||
return runtime_path
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,6 +1,6 @@
|
|||
local M = {}
|
||||
|
||||
function M.telescope_conf()
|
||||
function M.telescope()
|
||||
local telescope = require('telescope')
|
||||
|
||||
telescope.setup {
|
||||
|
@ -53,21 +53,18 @@ function M.telescope_conf()
|
|||
-- wrap lines inside preview pane
|
||||
vim.api.nvim_command('autocmd User TelescopePreviewerLoaded setlocal wrap')
|
||||
|
||||
-- Mappings for telescope-symbols.nvim
|
||||
vim.api.nvim_set_keymap('n', '<leader>fjg', ':lua require("telescope.builtin").symbols{sources = {"gitmoji"}, prompt_title = "Gitmoji"}<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>fjj', ':lua require("telescope.builtin").symbols{sources = {"emoji"}, prompt_title = "Emoji"}<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>fjk', ':lua require("telescope.builtin").symbols{sources = {"kaomoji"}, prompt_title = "Kaomoji"}<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>fjl', ':lua require("telescope.builtin").symbols{sources = {"julia"}, prompt_title = "Julia symbols"}<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>fjm', ':lua require("telescope.builtin").symbols{sources = {"math"}, prompt_title = "Math symbols"}<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>fjn', ':lua require("telescope.builtin").symbols{sources = {"nerd"}, prompt_title = "Nerd-fonts symbols"}<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>fjt', ':lua require("telescope.builtin").symbols{sources = {"latex"}, prompt_title = "Latex symbols"}<CR>', {noremap = true, silent = true})
|
||||
require('mappings').telescope_symbols()
|
||||
end
|
||||
|
||||
function M.octo_conf()
|
||||
function M.octo()
|
||||
require('octo').setup()
|
||||
end
|
||||
|
||||
function M.neogit_conf()
|
||||
function M.diffview()
|
||||
require('diffview').setup {diff_binaries = true}
|
||||
end
|
||||
|
||||
function M.neogit()
|
||||
require('neogit').setup {
|
||||
integrations = {
|
||||
diffview = true
|
||||
|
@ -75,11 +72,7 @@ function M.neogit_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.diffview_conf()
|
||||
require('diffview').setup {diff_binaries = true}
|
||||
end
|
||||
|
||||
function M.yabs_conf()
|
||||
function M.yabs()
|
||||
require('yabs'):setup {
|
||||
languages = {
|
||||
vim = {tasks = {run = {command = 'source %', type = 'vim'}}},
|
||||
|
@ -126,7 +119,7 @@ function M.yabs_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.markdown_preview_conf()
|
||||
function M.markdown_preview()
|
||||
vim.g.mkdp_refresh_slow = 1
|
||||
vim.g.mkdp_filetypes = {
|
||||
'markdown',
|
||||
|
@ -138,33 +131,12 @@ function M.markdown_preview_conf()
|
|||
-- vim.g.mkdp_echo_preview_url = 1
|
||||
end
|
||||
|
||||
function M.rest_conf()
|
||||
require('rest-nvim').setup {
|
||||
-- Open request results in a horizontal split
|
||||
result_split_horizontal = false,
|
||||
-- Skip SSL verification, useful for unknown certificates
|
||||
skip_ssl_verification = false,
|
||||
-- Highlight request on run
|
||||
highlight = {
|
||||
enabled = true,
|
||||
timeout = 150,
|
||||
},
|
||||
-- Jump to request line on run
|
||||
jump_to_request = false,
|
||||
}
|
||||
end
|
||||
|
||||
function M.spectre_conf()
|
||||
function M.spectre()
|
||||
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})
|
||||
require('mappings').spectre()
|
||||
end
|
||||
|
||||
function M.translate_conf()
|
||||
function M.translate_shell()
|
||||
vim.g.trans_join_lines = 1
|
||||
vim.g.trans_win_height = 15
|
||||
vim.g.trans_default_direction = ':ja'
|
||||
|
@ -181,7 +153,7 @@ function M.translate_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.undotree_conf()
|
||||
function M.undotree()
|
||||
vim.g.undotree_WindowLayout = 2
|
||||
vim.g.undotree_SplitWidth = 30
|
||||
vim.g.undotree_DiffpaneHeight = 10
|
||||
|
@ -189,7 +161,7 @@ function M.undotree_conf()
|
|||
vim.g.undotree_RelativeTimestamp = 1
|
||||
end
|
||||
|
||||
function M.toggleterm_conf()
|
||||
function M.toggleterm()
|
||||
require('toggleterm').setup {
|
||||
shade_terminals = false,
|
||||
float_opts = {
|
||||
|
@ -205,7 +177,7 @@ function M.toggleterm_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.sniprun_conf()
|
||||
function M.sniprun()
|
||||
local c = require('themes.' .. vim.g.colors_name .. '.colors')
|
||||
|
||||
require('sniprun').setup {
|
||||
|
@ -237,45 +209,32 @@ function M.sniprun_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.session_conf()
|
||||
function M.rest()
|
||||
require('rest-nvim').setup {
|
||||
-- Open request results in a horizontal split
|
||||
result_split_horizontal = false,
|
||||
-- Skip SSL verification, useful for unknown certificates
|
||||
skip_ssl_verification = false,
|
||||
-- Highlight request on run
|
||||
highlight = {
|
||||
enabled = true,
|
||||
timeout = 150,
|
||||
},
|
||||
-- Jump to request line on run
|
||||
jump_to_request = false,
|
||||
}
|
||||
end
|
||||
|
||||
function M.persistence()
|
||||
require('persistence').setup {
|
||||
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})
|
||||
require('mappings').persistence()
|
||||
end
|
||||
|
||||
function M.filetype_conf()
|
||||
require('filetype').setup {
|
||||
overrides = {
|
||||
extensions = {
|
||||
md = 'markdown',
|
||||
mkd = 'markdown',
|
||||
toml = 'toml',
|
||||
rasi = 'css',
|
||||
vifm = 'vim',
|
||||
log = 'log',
|
||||
LO = 'log'
|
||||
},
|
||||
literal = {
|
||||
vifmrc = 'vim'
|
||||
},
|
||||
complex = {
|
||||
['*_log'] = 'log',
|
||||
['G*_LOG'] = 'log',
|
||||
['.*waybar/config'] = 'jsonc',
|
||||
['.*lf/lfrc'] = 'sh'
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function M.closebuf_conf()
|
||||
function M.close_buffers()
|
||||
require('close_buffers').setup {
|
||||
preserve_window_layout = {'this'},
|
||||
next_buffer_cmd = function(windows)
|
||||
|
@ -289,7 +248,7 @@ function M.closebuf_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.winshift_conf()
|
||||
function M.winshift()
|
||||
require('winshift').setup {
|
||||
highlight_moving_win = true, -- Highlight the window being moved
|
||||
focused_hl_group = 'Visual', -- The highlight group used for the moving window
|
||||
|
@ -304,7 +263,7 @@ function M.winshift_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.winpicker_conf()
|
||||
function M.window_picker()
|
||||
require('window-picker').setup {
|
||||
keys = 'alskdjfhgwoeiruty',
|
||||
-- Swap windows by holding shift + letter
|
||||
|
@ -315,36 +274,10 @@ function M.winpicker_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.distant_conf()
|
||||
function M.distant()
|
||||
require('distant').setup {
|
||||
['*'] = require('distant.settings').chip_default()
|
||||
}
|
||||
end
|
||||
|
||||
function M.notify_conf()
|
||||
require('notify').setup {
|
||||
-- Animation style (see below for details)
|
||||
stages = 'fade_in_slide_out',
|
||||
-- Function called when a new window is opened, use for changing win settings/config
|
||||
on_open = nil,
|
||||
-- Render function for notifications. See notify-render()
|
||||
render = 'default',
|
||||
-- Default timeout for notifications
|
||||
timeout = 2000,
|
||||
-- For stages that change opacity this is treated as the highlight behind the window
|
||||
-- Set this to either a highlight group or an RGB hex value e.g. '#000000'
|
||||
background_colour = 'NormalFloat',
|
||||
-- Minimum width for notification windows
|
||||
minimum_width = 40,
|
||||
-- Icons for the different levels
|
||||
icons = {
|
||||
ERROR = '',
|
||||
WARN = '',
|
||||
INFO = '',
|
||||
DEBUG = '',
|
||||
TRACE = '✎'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
|
@ -0,0 +1,107 @@
|
|||
local M = {}
|
||||
local conf = require('modules.tools.config')
|
||||
|
||||
M['nvim-telescope/telescope.nvim'] = { -- TODO: check out fzf-lua
|
||||
keys = '<leader>fj',
|
||||
cmd = 'Telescope',
|
||||
wants = {
|
||||
'popup.nvim',
|
||||
'plenary.nvim',
|
||||
'nvim-notify',
|
||||
'yabs.nvim',
|
||||
'telescope-symbols.nvim',
|
||||
'telescope-project.nvim',
|
||||
'telescope-fzf-native.nvim'
|
||||
},
|
||||
requires = {
|
||||
{'FollieHiyuki/telescope-symbols.nvim', opt = true},
|
||||
{'nvim-telescope/telescope-project.nvim', opt = true},
|
||||
{'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = true}
|
||||
},
|
||||
config = conf.telescope
|
||||
}
|
||||
M['pwntester/octo.nvim'] = { -- TODO: colors + config
|
||||
cmd = 'Octo',
|
||||
wants = 'telescope.nvim',
|
||||
config = conf.octo
|
||||
}
|
||||
M['TimUntersberger/neogit'] = {
|
||||
cmd = 'Neogit',
|
||||
wants = {'diffview.nvim', 'plenary.nvim'},
|
||||
requires = {{
|
||||
'sindrets/diffview.nvim',
|
||||
cmd = {
|
||||
'DiffviewOpen','DiffviewClose',
|
||||
'DiffviewToggleFiles', 'DiffviewFocusFiles'
|
||||
},
|
||||
config = conf.diffview,
|
||||
opt = true
|
||||
}},
|
||||
config = conf.neogit
|
||||
}
|
||||
M['pianocomposer321/yabs.nvim'] = {
|
||||
cmd = {'YabsTask', 'YabsDefaultTask'},
|
||||
config = conf.yabs
|
||||
}
|
||||
M['iamcco/markdown-preview.nvim'] = { -- TODO: check out kat0h/bufpreview.vim
|
||||
run = 'cd app && yarn install',
|
||||
ft = {'markdown', 'rmd'},
|
||||
config = conf.markdown_preview
|
||||
}
|
||||
M['turbio/bracey.vim'] = {
|
||||
run = 'npm install --prefix server',
|
||||
cmd = 'Bracey'
|
||||
}
|
||||
M['windwp/nvim-spectre'] = {
|
||||
keys = '<leader>p',
|
||||
wants = 'plenary.nvim',
|
||||
config = conf.spectre
|
||||
}
|
||||
M['echuraev/translate-shell.vim'] = {
|
||||
cmd = {'Trans', 'TransSelectDirection'},
|
||||
config = conf.translate_shell
|
||||
}
|
||||
M['mbbill/undotree'] = {
|
||||
cmd = 'UndotreeToggle',
|
||||
setup = conf.undotree
|
||||
}
|
||||
M['akinsho/toggleterm.nvim'] = {
|
||||
cmd = 'ToggleTerm',
|
||||
config = conf.toggleterm
|
||||
}
|
||||
M['michaelb/sniprun'] = {
|
||||
run = 'cargo build --release',
|
||||
cmd = 'SnipRun',
|
||||
wants = 'nvim-notify',
|
||||
config = conf.sniprun
|
||||
}
|
||||
M['NTBBloodbath/rest.nvim'] = {
|
||||
keys = {'<Plug>RestNvim', '<Plug>RestNvimPreview', '<Plug>RestNvimLast'},
|
||||
wants = {'plenary.nvim', 'nvim-treesitter'},
|
||||
config = conf.rest
|
||||
}
|
||||
M['folke/persistence.nvim'] = { -- TODO: check out auto-session + session-lens
|
||||
event = 'BufReadPre',
|
||||
keys = '<leader>s',
|
||||
config = conf.persistence
|
||||
}
|
||||
M['kazhala/close-buffers.nvim'] = {
|
||||
cmd = {'BDelete', 'BWipeout'},
|
||||
wants = 'bufferline.nvim',
|
||||
config = conf.close_buffers
|
||||
}
|
||||
M['sindrets/winshift.nvim'] = {
|
||||
cmd = 'WinShift',
|
||||
config = conf.winshift
|
||||
}
|
||||
M['ten3roberts/window-picker.nvim'] = {
|
||||
cmd = {'WindowPick', 'WindowSwap', 'WindowSwapStay'},
|
||||
config = conf.window_picker
|
||||
}
|
||||
M['chipsenkbeil/distant.nvim'] = {
|
||||
cmd = {'DistantInstall', 'DistantLaunch'},
|
||||
config = conf.distant
|
||||
}
|
||||
M['dstein64/vim-startuptime'] = {cmd = 'StartupTime'} -- Just for benchmarking
|
||||
|
||||
return M
|
|
@ -0,0 +1,229 @@
|
|||
local M = {}
|
||||
local colors = require('themes.' .. vim.g.colors_name .. '.colors')
|
||||
local vi_mode_utils = require('feline.providers.vi_mode')
|
||||
local lightbulb_present, lightbulb = pcall(require, 'nvim-lightbulb')
|
||||
-- local gps_present, gps = pcall(require, 'nvim-gps')
|
||||
|
||||
local function file_osinfo()
|
||||
local os = vim.bo.fileformat:upper()
|
||||
local icon = {}
|
||||
if os == 'UNIX' then
|
||||
icon = ' '
|
||||
elseif os == 'MAC' then
|
||||
icon = ' '
|
||||
else
|
||||
icon = ' '
|
||||
end
|
||||
return icon .. os
|
||||
end
|
||||
|
||||
local function buffer_not_empty()
|
||||
if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Default colors for statusline --
|
||||
M['normal_colors'] = {bg = colors.grey1, fg = colors.fg}
|
||||
M['vi_mode_colors'] = {
|
||||
NORMAL = colors.green,
|
||||
OP = colors.green,
|
||||
INSERT = colors.blue,
|
||||
VISUAL = colors.yellow,
|
||||
LINES = colors.yellow,
|
||||
BLOCK = colors.yellow,
|
||||
REPLACE = colors.red,
|
||||
['V-REPLACE'] = colors.red,
|
||||
ENTER = colors.cyan,
|
||||
MORE = colors.cyan,
|
||||
SELECT = colors.orange,
|
||||
COMMAND = colors.purple,
|
||||
SHELL = colors.green,
|
||||
TERM = colors.green,
|
||||
NONE = colors.white2
|
||||
}
|
||||
|
||||
-- Components --
|
||||
M['dummy'] = {
|
||||
provider = '▊',
|
||||
hl = {fg = colors.blue},
|
||||
right_sep = ' '
|
||||
}
|
||||
|
||||
M['vi_mode'] = {
|
||||
provider = ' ',
|
||||
hl = function()
|
||||
return {
|
||||
name = vi_mode_utils.get_mode_highlight_name(),
|
||||
fg = vi_mode_utils.get_mode_color()
|
||||
}
|
||||
end,
|
||||
right_sep = ' '
|
||||
}
|
||||
|
||||
M['filesize'] = {
|
||||
provider = 'file_size',
|
||||
enabled = buffer_not_empty,
|
||||
hl = {fg = colors.fg, style = 'bold'},
|
||||
right_sep = ' '
|
||||
}
|
||||
|
||||
M['fileinfo'] = {
|
||||
provider = {
|
||||
name = 'file_info',
|
||||
opts = {
|
||||
file_modified_icon = ' ',
|
||||
file_readonly_icon = ' ',
|
||||
type = 'base-only' -- relative, unique, full-path, short-path, relative-short, unique-short
|
||||
}
|
||||
},
|
||||
enabled = buffer_not_empty,
|
||||
hl = {fg = colors.blue, style = 'bold'},
|
||||
right_sep = ' '
|
||||
}
|
||||
|
||||
M['lineinfo'] = {
|
||||
provider = 'position',
|
||||
hl = {fg = colors.fg},
|
||||
right_sep = ' '
|
||||
}
|
||||
|
||||
M['percent'] = {
|
||||
provider = 'line_percentage',
|
||||
hl = {fg = colors.fg, style = 'bold'},
|
||||
right_sep = ' '
|
||||
}
|
||||
|
||||
-- M['gps'] = {
|
||||
-- provider = function()
|
||||
-- return gps.get_location()
|
||||
-- end,
|
||||
-- enabled = function()
|
||||
-- if gps_present then
|
||||
-- return gps.is_available()
|
||||
-- else
|
||||
-- return false
|
||||
-- end
|
||||
-- end,
|
||||
-- hl = {fg = colors.cyan}
|
||||
-- }
|
||||
|
||||
M['codeact'] = {
|
||||
provider = function()
|
||||
return lightbulb.get_status_text()
|
||||
end,
|
||||
enabled = function()
|
||||
return lightbulb_present
|
||||
end,
|
||||
hl = {fg = colors.green, style = 'bold'}
|
||||
}
|
||||
|
||||
M['diagerr'] = {
|
||||
provider = 'diagnostic_errors',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.red},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['diagwarn'] = {
|
||||
provider = 'diagnostic_warnings',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.yellow},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['diaghint'] = {
|
||||
provider = 'diagnostic_hints',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.cyan},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['diaginfo'] = {
|
||||
provider = 'diagnostic_info',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.blue},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['lspclient'] = {
|
||||
provider = function()
|
||||
local clients = {}
|
||||
|
||||
-- Typical lsp clients
|
||||
for _, client in pairs(vim.lsp.buf_get_clients(0)) do
|
||||
if client.name ~= 'null-ls' then
|
||||
table.insert(clients, client.name)
|
||||
end
|
||||
end
|
||||
|
||||
-- null-ls sources
|
||||
local null_ls_methods = require('null-ls.methods')
|
||||
local active_sources = require('null-ls.info').get_active_sources()
|
||||
|
||||
local linter_method = null_ls_methods.internal['DIAGNOSTICS']
|
||||
local active_linters = active_sources[linter_method] or {}
|
||||
vim.list_extend(clients, active_linters)
|
||||
|
||||
local formatter_method = null_ls_methods.internal['FORMATTING']
|
||||
local active_formatters = active_sources[formatter_method] or {}
|
||||
vim.list_extend(clients, active_formatters)
|
||||
|
||||
return table.concat(clients, ', ')
|
||||
end,
|
||||
enabled = function()
|
||||
return next(vim.lsp.buf_get_clients(0)) ~= nil
|
||||
end,
|
||||
icon = ' LSP:',
|
||||
hl = {fg = colors.purple, style = 'bold'},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['format'] = {
|
||||
provider = file_osinfo,
|
||||
hl = {fg = colors.cyan},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['encode'] = {
|
||||
provider = 'file_encoding',
|
||||
hl = {fg = colors.fg},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['filetype'] = {
|
||||
provider = 'file_type',
|
||||
hl = {fg = colors.blue, style = 'bold'},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['gitbranch'] = {
|
||||
provider = 'git_branch',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.green, style = 'bold'},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['diffadd'] = {
|
||||
provider = 'git_diff_added',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.green},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['diffchange'] = {
|
||||
provider = 'git_diff_changed',
|
||||
icon = '柳',
|
||||
hl = {fg = colors.yellow},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
M['diffremove'] = {
|
||||
provider = 'git_diff_removed',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.red},
|
||||
left_sep = ' '
|
||||
}
|
||||
|
||||
return M
|
|
@ -1,6 +1,6 @@
|
|||
local M = {}
|
||||
|
||||
function M.dashboard_conf()
|
||||
function M.dashboard()
|
||||
local dashboard = require('alpha.themes.dashboard')
|
||||
|
||||
dashboard.section.header = {
|
||||
|
@ -24,14 +24,14 @@ function M.dashboard_conf()
|
|||
|
||||
dashboard.section.footer = {
|
||||
type = 'text',
|
||||
val = 'おかえりなさい',
|
||||
val = '☆*:.。. o(≧▽≦)o .。.:*☆',
|
||||
opts = {
|
||||
position = 'center',
|
||||
hl = 'DashboardFooter'
|
||||
}
|
||||
}
|
||||
|
||||
local button = function(sc, txt, keybind, keybind_opts)
|
||||
dashboard.button = function(sc, txt, keybind, keybind_opts)
|
||||
local sc_ = sc:gsub('%s', ''):gsub('SPC', '<leader>')
|
||||
|
||||
local opts = {
|
||||
|
@ -61,6 +61,7 @@ function M.dashboard_conf()
|
|||
}
|
||||
end
|
||||
|
||||
local button = dashboard.button
|
||||
dashboard.section.buttons = {
|
||||
type = 'group',
|
||||
val = {
|
||||
|
@ -87,195 +88,12 @@ function M.dashboard_conf()
|
|||
}
|
||||
|
||||
-- Hide tabline in dashboard buffer
|
||||
vim.api.nvim_command [[
|
||||
autocmd FileType alpha set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2
|
||||
]]
|
||||
vim.api.nvim_command('autocmd FileType alpha set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2')
|
||||
end
|
||||
|
||||
function M.statusline_conf()
|
||||
local colors = require('themes.' .. vim.g.colors_name .. '.colors')
|
||||
|
||||
local vi_mode_colors = {
|
||||
NORMAL = colors.green,
|
||||
OP = colors.green,
|
||||
INSERT = colors.blue,
|
||||
VISUAL = colors.yellow,
|
||||
LINES = colors.yellow,
|
||||
BLOCK = colors.yellow,
|
||||
REPLACE = colors.red,
|
||||
['V-REPLACE'] = colors.red,
|
||||
ENTER = colors.cyan,
|
||||
MORE = colors.cyan,
|
||||
SELECT = colors.orange,
|
||||
COMMAND = colors.purple,
|
||||
SHELL = colors.green,
|
||||
TERM = colors.green,
|
||||
NONE = colors.white2
|
||||
}
|
||||
|
||||
local function file_osinfo()
|
||||
local os = vim.bo.fileformat:upper()
|
||||
local icon
|
||||
if os == 'UNIX' then
|
||||
icon = ' '
|
||||
elseif os == 'MAC' then
|
||||
icon = ' '
|
||||
else
|
||||
icon = ' '
|
||||
end
|
||||
return icon .. os
|
||||
end
|
||||
|
||||
local function buffer_not_empty()
|
||||
if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local vi_mode_utils = require('feline.providers.vi_mode')
|
||||
local lightbulb_present, lightbulb = pcall(require, 'nvim-lightbulb')
|
||||
local gps_present, gps = pcall(require, 'nvim-gps')
|
||||
|
||||
local comps = {
|
||||
dummy = {
|
||||
provider = '▊',
|
||||
hl = {fg = colors.blue},
|
||||
right_sep = ' '
|
||||
},
|
||||
vi_mode = {
|
||||
provider = ' ',
|
||||
hl = function()
|
||||
return {
|
||||
name = vi_mode_utils.get_mode_highlight_name(),
|
||||
fg = vi_mode_utils.get_mode_color()
|
||||
}
|
||||
end,
|
||||
right_sep = ' '
|
||||
},
|
||||
filesize = {
|
||||
provider = 'file_size',
|
||||
enabled = buffer_not_empty,
|
||||
hl = {fg = colors.fg, style = 'bold'},
|
||||
right_sep = ' '
|
||||
},
|
||||
fileinfo = {
|
||||
provider = {
|
||||
name = 'file_info',
|
||||
opts = {
|
||||
file_modified_icon = ' ',
|
||||
file_readonly_icon = ' ',
|
||||
type = 'base-only' -- relative, unique, full-path, short-path, relative-short, unique-short
|
||||
}
|
||||
},
|
||||
enabled = buffer_not_empty,
|
||||
hl = {fg = colors.blue, style = 'bold'},
|
||||
right_sep = ' '
|
||||
},
|
||||
lineinfo = {
|
||||
provider = 'position',
|
||||
hl = {fg = colors.fg},
|
||||
right_sep = ' '
|
||||
},
|
||||
percent = {
|
||||
provider = 'line_percentage',
|
||||
hl = {fg = colors.fg, style = 'bold'},
|
||||
right_sep = ' '
|
||||
},
|
||||
gps = {
|
||||
provider = function()
|
||||
return gps.get_location()
|
||||
end,
|
||||
enabled = function()
|
||||
if gps_present then
|
||||
return gps.is_available()
|
||||
else
|
||||
return false
|
||||
end
|
||||
end,
|
||||
hl = {fg = colors.cyan}
|
||||
},
|
||||
codeact = {
|
||||
provider = function()
|
||||
return lightbulb.get_status_text()
|
||||
end,
|
||||
enabled = function()
|
||||
return lightbulb_present
|
||||
end,
|
||||
hl = {fg = colors.green, style = 'bold'}
|
||||
},
|
||||
diagerr = {
|
||||
provider = 'diagnostic_errors',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.red},
|
||||
left_sep = ' '
|
||||
},
|
||||
diagwarn = {
|
||||
provider = 'diagnostic_warnings',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.yellow},
|
||||
left_sep = ' '
|
||||
},
|
||||
diaghint = {
|
||||
provider = 'diagnostic_hints',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.cyan},
|
||||
left_sep = ' '
|
||||
},
|
||||
diaginfo = {
|
||||
provider = 'diagnostic_info',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.blue},
|
||||
left_sep = ' '
|
||||
},
|
||||
lspclient = {
|
||||
provider = 'lsp_client_names',
|
||||
icon = ' LSP:',
|
||||
hl = {fg = colors.purple, style = 'bold'},
|
||||
left_sep = ' '
|
||||
},
|
||||
format = {
|
||||
provider = file_osinfo,
|
||||
hl = {fg = colors.cyan},
|
||||
left_sep = ' '
|
||||
},
|
||||
encode = {
|
||||
provider = 'file_encoding',
|
||||
hl = {fg = colors.fg},
|
||||
left_sep = ' '
|
||||
},
|
||||
filetype = {
|
||||
provider = 'file_type',
|
||||
hl = {fg = colors.blue, style = 'bold'},
|
||||
left_sep = ' '
|
||||
},
|
||||
gitbranch = {
|
||||
provider = 'git_branch',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.green, style = 'bold'},
|
||||
left_sep = ' '
|
||||
},
|
||||
diffadd = {
|
||||
provider = 'git_diff_added',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.green},
|
||||
left_sep = ' '
|
||||
},
|
||||
diffchange = {
|
||||
provider = 'git_diff_changed',
|
||||
icon = '柳',
|
||||
hl = {fg = colors.yellow},
|
||||
left_sep = ' '
|
||||
},
|
||||
diffremove = {
|
||||
provider = 'git_diff_removed',
|
||||
icon = ' ',
|
||||
hl = {fg = colors.red},
|
||||
left_sep = ' '
|
||||
}
|
||||
}
|
||||
|
||||
function M.statusline()
|
||||
-- Initialize the components table before defining it
|
||||
local comps = require('modules.ui.components')
|
||||
local components = {
|
||||
active = {},
|
||||
inactive = {}
|
||||
|
@ -293,7 +111,7 @@ 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.gps)
|
||||
-- table.insert(components.active[1], comps.gps)
|
||||
table.insert(components.active[3], comps.codeact)
|
||||
table.insert(components.active[3], comps.diagerr)
|
||||
table.insert(components.active[3], comps.diagwarn)
|
||||
|
@ -312,9 +130,9 @@ function M.statusline_conf()
|
|||
table.insert(components.inactive[2], comps.filetype)
|
||||
|
||||
require('feline').setup {
|
||||
colors = {bg = colors.grey1, fg = colors.fg},
|
||||
colors = comps.normal_colors,
|
||||
components = components,
|
||||
vi_mode_colors = vi_mode_colors,
|
||||
vi_mode_colors = comps.vi_mode_colors,
|
||||
force_inactive = {
|
||||
filetypes = {
|
||||
'packer',
|
||||
|
@ -332,7 +150,7 @@ function M.statusline_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.bufferline_conf()
|
||||
function M.bufferline()
|
||||
require('bufferline').setup {
|
||||
options = {
|
||||
numbers = 'none',
|
||||
|
@ -376,7 +194,7 @@ function M.bufferline_conf()
|
|||
end
|
||||
|
||||
-- FIX: wait for config migration to setup()
|
||||
function M.nvimtree_conf()
|
||||
function M.nvimtree()
|
||||
vim.g.nvim_tree_gitignore = 1
|
||||
vim.g.nvim_tree_ignore = {'.git', '.hg', '.svn', 'node_modules'}
|
||||
vim.g.nvim_tree_auto_ignore_ft = {'dashboard', 'alpha'}
|
||||
|
@ -453,7 +271,7 @@ function M.nvimtree_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.whichkey_conf()
|
||||
function M.whichkey()
|
||||
require('which-key').setup {
|
||||
plugins = {
|
||||
spelling = {
|
||||
|
@ -472,7 +290,7 @@ function M.whichkey_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.gitsigns_conf()
|
||||
function M.gitsigns()
|
||||
require('gitsigns').setup {
|
||||
signs = {
|
||||
add = {hl = 'DiffAdd' , text = '', numhl='GitSignsAddNr'},
|
||||
|
@ -544,71 +362,69 @@ function M.gitsigns_conf()
|
|||
}
|
||||
end
|
||||
|
||||
function M.lightbulb_conf()
|
||||
vim.api.nvim_command [[
|
||||
autocmd CursorHold * lua require('nvim-lightbulb').update_lightbulb({sign = {enabled = false}, status_text = {enabled = true, text = ' Code action', text_unavailable = ''}})
|
||||
]]
|
||||
function M.lightbulb()
|
||||
vim.api.nvim_command('autocmd CursorHold * lua require("nvim-lightbulb").update_lightbulb({sign = {enabled = false}, status_text = {enabled = true, text = " Code action", text_unavailable = ""}})')
|
||||
end
|
||||
|
||||
function M.gps_conf()
|
||||
require('nvim-gps').setup {
|
||||
icons = {
|
||||
['class-name'] = '𝓒 ',
|
||||
['function-name'] = 'ƒ ',
|
||||
['method-name'] = ' ',
|
||||
['container-name'] = ' ',
|
||||
['tag-name'] = '炙'
|
||||
},
|
||||
-- Add custom configuration per language or
|
||||
-- Disable the plugin for a language
|
||||
-- Any language not disabled here is enabled by default
|
||||
languages = {
|
||||
-- Some languages have custom icons
|
||||
['json'] = {
|
||||
icons = {
|
||||
['array-name'] = ' ',
|
||||
['object-name'] = ' ',
|
||||
['null-name'] = '[] ',
|
||||
['boolean-name'] = 'ﰰﰴ ',
|
||||
['number-name'] = '# ',
|
||||
['string-name'] = ' '
|
||||
}
|
||||
},
|
||||
['toml'] = {
|
||||
icons = {
|
||||
['table-name'] = ' ',
|
||||
['array-name'] = ' ',
|
||||
['boolean-name'] = 'ﰰﰴ ',
|
||||
['date-name'] = ' ',
|
||||
['date-time-name'] = ' ',
|
||||
['float-name'] = ' ',
|
||||
['inline-table-name'] = ' ',
|
||||
['integer-name'] = '# ',
|
||||
['string-name'] = ' ',
|
||||
['time-name'] = ' '
|
||||
}
|
||||
},
|
||||
['verilog'] = {
|
||||
icons = {
|
||||
['module-name'] = ' '
|
||||
}
|
||||
},
|
||||
['yaml'] = {
|
||||
icons = {
|
||||
['mapping-name'] = ' ',
|
||||
['sequence-name'] = ' ',
|
||||
['null-name'] = '[] ',
|
||||
['boolean-name'] = 'ﰰﰴ ',
|
||||
['integer-name'] = '# ',
|
||||
['float-name'] = ' ',
|
||||
['string-name'] = ' '
|
||||
}
|
||||
}
|
||||
},
|
||||
separator = ' ',
|
||||
depth = 0,
|
||||
depth_limit_indicator = '..'
|
||||
}
|
||||
end
|
||||
-- function M.gps()
|
||||
-- require('nvim-gps').setup {
|
||||
-- icons = {
|
||||
-- ['class-name'] = '𝓒 ',
|
||||
-- ['function-name'] = 'ƒ ',
|
||||
-- ['method-name'] = ' ',
|
||||
-- ['container-name'] = ' ',
|
||||
-- ['tag-name'] = '炙'
|
||||
-- },
|
||||
-- -- Add custom configuration per language or
|
||||
-- -- Disable the plugin for a language
|
||||
-- -- Any language not disabled here is enabled by default
|
||||
-- languages = {
|
||||
-- -- Some languages have custom icons
|
||||
-- ['json'] = {
|
||||
-- icons = {
|
||||
-- ['array-name'] = ' ',
|
||||
-- ['object-name'] = ' ',
|
||||
-- ['null-name'] = '[] ',
|
||||
-- ['boolean-name'] = 'ﰰﰴ ',
|
||||
-- ['number-name'] = '# ',
|
||||
-- ['string-name'] = ' '
|
||||
-- }
|
||||
-- },
|
||||
-- ['toml'] = {
|
||||
-- icons = {
|
||||
-- ['table-name'] = ' ',
|
||||
-- ['array-name'] = ' ',
|
||||
-- ['boolean-name'] = 'ﰰﰴ ',
|
||||
-- ['date-name'] = ' ',
|
||||
-- ['date-time-name'] = ' ',
|
||||
-- ['float-name'] = ' ',
|
||||
-- ['inline-table-name'] = ' ',
|
||||
-- ['integer-name'] = '# ',
|
||||
-- ['string-name'] = ' ',
|
||||
-- ['time-name'] = ' '
|
||||
-- }
|
||||
-- },
|
||||
-- ['verilog'] = {
|
||||
-- icons = {
|
||||
-- ['module-name'] = ' '
|
||||
-- }
|
||||
-- },
|
||||
-- ['yaml'] = {
|
||||
-- icons = {
|
||||
-- ['mapping-name'] = ' ',
|
||||
-- ['sequence-name'] = ' ',
|
||||
-- ['null-name'] = '[] ',
|
||||
-- ['boolean-name'] = 'ﰰﰴ ',
|
||||
-- ['integer-name'] = '# ',
|
||||
-- ['float-name'] = ' ',
|
||||
-- ['string-name'] = ' '
|
||||
-- }
|
||||
-- }
|
||||
-- },
|
||||
-- separator = ' ',
|
||||
-- depth = 0,
|
||||
-- depth_limit_indicator = '..'
|
||||
-- }
|
||||
-- end
|
||||
|
||||
return M
|
|
@ -0,0 +1,38 @@
|
|||
local M = {}
|
||||
local conf = require('modules.ui.config')
|
||||
|
||||
M['goolord/alpha-nvim'] = {
|
||||
event = 'VimEnter',
|
||||
config = conf.dashboard
|
||||
}
|
||||
M['famiu/feline.nvim'] = {
|
||||
event = 'VimEnter',
|
||||
wants = 'nvim-web-devicons',
|
||||
config = conf.statusline
|
||||
}
|
||||
M['akinsho/bufferline.nvim'] = {
|
||||
event = {'BufRead', 'BufNewFile'},
|
||||
config = conf.bufferline
|
||||
}
|
||||
M['kyazdani42/nvim-tree.lua'] = {
|
||||
cmd = 'NvimTreeToggle',
|
||||
config = conf.nvimtree
|
||||
}
|
||||
M['folke/which-key.nvim'] = {
|
||||
config = conf.whichkey
|
||||
}
|
||||
M['lewis6991/gitsigns.nvim'] = {
|
||||
event = {'BufRead', 'BufNewFile'},
|
||||
wants = 'plenary.nvim',
|
||||
config = conf.gitsigns
|
||||
}
|
||||
M['kosayoda/nvim-lightbulb'] = {
|
||||
after = 'nvim-lspconfig',
|
||||
config = conf.lightbulb
|
||||
}
|
||||
-- M['SmiteshP/nvim-gps'] = {
|
||||
-- after = 'nvim-treesitter',
|
||||
-- config = conf.gps
|
||||
-- }
|
||||
|
||||
return M
|
|
@ -1,469 +1,41 @@
|
|||
-- TODO: rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, nvim-comment-frame,
|
||||
-- nvim-revJ.lua, nvim-remote-containers, tex.nvim, telescope-dap.nvim, fcitx.nvim,
|
||||
-- pandoc.nvim, qf_helper.nvim
|
||||
local packer = require('modules.pack')
|
||||
-- pandoc.nvim, qf_helper.nvim, tldr.nvim
|
||||
local M = {}
|
||||
local packer = require('modules.core.pack')
|
||||
local modules_dir = vim.fn.stdpath('config') .. '/lua/modules'
|
||||
|
||||
-- This is recommended when using `luafile <afile>` a lot
|
||||
packer.reset()
|
||||
|
||||
-- Necessary stuff
|
||||
local needed_plugins = function(use)
|
||||
use {'wbthomason/packer.nvim', opt = true}
|
||||
|
||||
use {'kyazdani42/nvim-web-devicons', module = 'nvim-web-devicons'}
|
||||
use {'nvim-lua/plenary.nvim', module = 'plenary'}
|
||||
use {'nvim-lua/popup.nvim', module = 'popup'}
|
||||
local function get_plugins_list()
|
||||
local list = {}
|
||||
local tmp = vim.split(vim.fn.globpath(modules_dir, '*/plugins.lua'), '\n')
|
||||
for _, f in ipairs(tmp) do
|
||||
list[#list + 1] = f:sub(#modules_dir - 6, -1)
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
-- UI components
|
||||
local ui = require('modules.ui')
|
||||
local ui_plugins = function(use)
|
||||
use {
|
||||
'goolord/alpha-nvim',
|
||||
event = 'VimEnter',
|
||||
config = ui.dashboard_conf
|
||||
}
|
||||
use {
|
||||
'famiu/feline.nvim',
|
||||
event = 'VimEnter',
|
||||
wants = 'nvim-web-devicons',
|
||||
config = ui.statusline_conf
|
||||
}
|
||||
use {
|
||||
'akinsho/bufferline.nvim',
|
||||
event = {'BufRead', 'BufNewFile'},
|
||||
config = ui.bufferline_conf
|
||||
}
|
||||
use {
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
cmd = 'NvimTreeToggle',
|
||||
config = ui.nvimtree_conf
|
||||
}
|
||||
use {
|
||||
'folke/which-key.nvim',
|
||||
config = ui.whichkey_conf
|
||||
}
|
||||
use {
|
||||
'lewis6991/gitsigns.nvim',
|
||||
event = {'BufRead', 'BufNewFile'},
|
||||
wants = 'plenary.nvim',
|
||||
config = ui.gitsigns_conf
|
||||
}
|
||||
use {
|
||||
'kosayoda/nvim-lightbulb',
|
||||
after = 'nvim-lspconfig',
|
||||
config = ui.lightbulb_conf
|
||||
}
|
||||
use {
|
||||
'SmiteshP/nvim-gps',
|
||||
after = 'nvim-treesitter',
|
||||
config = ui.gps_conf
|
||||
}
|
||||
function M.load_plugins()
|
||||
local repos = {}
|
||||
|
||||
-- Merge all plugins' definitions into a table
|
||||
local plugins_file = get_plugins_list()
|
||||
for _, m in ipairs(plugins_file) do
|
||||
local local_repos = require(m:sub(0, #m - 4))
|
||||
for repo, conf in pairs(local_repos) do
|
||||
repos[#repos + 1] = vim.tbl_extend('force', {repo}, conf)
|
||||
end
|
||||
end
|
||||
|
||||
-- This is recommended when using `luafile <afile>` a lot
|
||||
packer.reset()
|
||||
|
||||
packer.startup(function(use)
|
||||
for _, repo in ipairs(repos) do
|
||||
use(repo)
|
||||
end
|
||||
-- Install plugins if missing
|
||||
packer.install()
|
||||
end)
|
||||
end
|
||||
|
||||
-- Editing-related plugins
|
||||
local editor = require('modules.editor')
|
||||
local editor_plugins = function(use)
|
||||
use {
|
||||
'norcalli/nvim-colorizer.lua',
|
||||
cmd = 'ColorizerToggle',
|
||||
config = editor.colorizer_conf
|
||||
}
|
||||
-- use { -- TODO: check out treesitter support, otherwise use nvim-treesitter-refactor
|
||||
-- 'RRethy/vim-illuminate',
|
||||
-- event = 'CursorHold',
|
||||
-- setup = editor.illuminate_conf
|
||||
-- }
|
||||
use { -- TODO: config, check out fennel-repl.nvim
|
||||
'Olical/conjure',
|
||||
ft = {'clojure', 'fennel', 'scheme', 'hy', 'janet', 'racket'}
|
||||
}
|
||||
use { -- TODO: highlights, check out neorg
|
||||
'kristijanhusak/orgmode.nvim',
|
||||
ft = 'org',
|
||||
requires = {{
|
||||
'akinsho/org-bullets.nvim',
|
||||
after = 'orgmode.nvim',
|
||||
config = editor.bullets_conf
|
||||
}},
|
||||
config = editor.orgmode_conf
|
||||
}
|
||||
use {
|
||||
'lukas-reineke/headlines.nvim',
|
||||
ft = {'org', 'markdown'},
|
||||
config = editor.headlines_conf
|
||||
}
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = ':TSUpdate',
|
||||
event = 'BufRead',
|
||||
config = editor.treesitter_conf
|
||||
}
|
||||
use {'nvim-treesitter/playground', after = 'nvim-treesitter'}
|
||||
use {'nvim-treesitter/nvim-treesitter-refactor', after = 'nvim-treesitter'}
|
||||
use {'nvim-treesitter/nvim-treesitter-textobjects', after = 'nvim-treesitter'}
|
||||
use {'p00f/nvim-ts-rainbow', after = 'nvim-treesitter'}
|
||||
use {'windwp/nvim-ts-autotag', after = 'nvim-treesitter'}
|
||||
use {'romgrk/nvim-treesitter-context', after = 'nvim-treesitter'}
|
||||
use {'JoosepAlviste/nvim-ts-context-commentstring', after = 'nvim-treesitter'}
|
||||
-- use {
|
||||
-- 'spywhere/detect-language.nvim',
|
||||
-- event = 'BufNewFile',
|
||||
-- config = editor.detect_conf
|
||||
-- }
|
||||
use {
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
after = 'nvim-treesitter',
|
||||
config = editor.blankline_conf
|
||||
}
|
||||
use {
|
||||
'mizlan/iswap.nvim',
|
||||
cmd = {'ISwapWith', 'ISwap'},
|
||||
wants = 'nvim-treesitter',
|
||||
config = editor.iswap_conf
|
||||
}
|
||||
use {
|
||||
'andymass/vim-matchup',
|
||||
after = 'nvim-treesitter',
|
||||
config = editor.matchup_conf
|
||||
}
|
||||
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 { -- TODO: check out lightspeed.nvim
|
||||
'phaazon/hop.nvim',
|
||||
cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'},
|
||||
config = editor.hop_conf
|
||||
}
|
||||
use {
|
||||
'hrsh7th/vim-eft',
|
||||
keys = {
|
||||
{'n', 'f'}, {'x', 'f'}, {'n', 'F'}, {'x', 'F'},
|
||||
{'n', 't'}, {'x', 't'}, {'n', 'T'}, {'x', 'T'},
|
||||
{'n', ';'}, {'x', ';'}
|
||||
},
|
||||
config = editor.eft_conf
|
||||
}
|
||||
use {
|
||||
'monaqa/dial.nvim',
|
||||
keys = {
|
||||
{'n', '<C-a>'}, {'v', '<C-a>'}, {'v', 'g<C-a>'},
|
||||
{'n', '<C-x>'}, {'v', '<C-x>'}, {'v', 'g<C-x>'}
|
||||
},
|
||||
config = editor.dial_conf
|
||||
}
|
||||
use {'junegunn/vim-easy-align', cmd = {'EasyAlign', 'LiveEasyAlign'}}
|
||||
use {
|
||||
'dhruvasagar/vim-table-mode',
|
||||
cmd = {'Tableize', 'TableModeToggle', 'TableModeRealign'},
|
||||
setup = editor.table_conf
|
||||
}
|
||||
use {
|
||||
'numToStr/Comment.nvim',
|
||||
keys = {'gc', 'gb'},
|
||||
wants = 'nvim-ts-context-commentstring',
|
||||
config = editor.comment_conf
|
||||
}
|
||||
use {
|
||||
'winston0410/range-highlight.nvim',
|
||||
event = 'CmdlineEnter',
|
||||
wants = 'cmd-parser.nvim',
|
||||
requires = {{'winston0410/cmd-parser.nvim', opt = true}},
|
||||
config = editor.range_conf
|
||||
}
|
||||
use {
|
||||
'danymat/neogen',
|
||||
keys = '<leader>eg',
|
||||
wants = 'nvim-treesitter',
|
||||
config = editor.neogen_conf
|
||||
}
|
||||
use {
|
||||
'gpanders/editorconfig.nvim',
|
||||
event = {'BufRead', 'BufNewFile'}
|
||||
}
|
||||
use { -- TODO: move to nvim-parinfer (lua)
|
||||
'eraserhd/parinfer-rust',
|
||||
run = 'cargo build --release',
|
||||
ft = {'clojure', 'lisp', 'scheme', 'fennel', 'racket', 'hy', 'janet', 'carp', 'wast'}
|
||||
}
|
||||
use {
|
||||
'ahmedkhalf/project.nvim',
|
||||
event = 'BufEnter',
|
||||
config = editor.project_conf
|
||||
}
|
||||
use {
|
||||
'ruifm/gitlinker.nvim',
|
||||
wants = 'plenary.nvim',
|
||||
keys = {'<leader>gy', '<leader>gY'},
|
||||
config = editor.gitlinker_conf
|
||||
}
|
||||
use {'jbyuki/venn.nvim', cmd = 'VBox'}
|
||||
end
|
||||
|
||||
-- LSP-related
|
||||
local lsp = require('modules.lsp')
|
||||
local lsp_plugins = function(use)
|
||||
use {
|
||||
'neovim/nvim-lspconfig',
|
||||
event = 'BufReadPre',
|
||||
wants = {'lsp_signature.nvim', 'lspsaga.nvim', 'SchemaStore.nvim'},
|
||||
requires = {
|
||||
{
|
||||
'ray-x/lsp_signature.nvim',
|
||||
config = lsp.signature_conf,
|
||||
opt = true
|
||||
},
|
||||
{
|
||||
'tami5/lspsaga.nvim',
|
||||
branch = 'nvim51',
|
||||
config = lsp.saga_conf,
|
||||
opt = true
|
||||
},
|
||||
{'b0o/SchemaStore.nvim', opt = true}
|
||||
},
|
||||
config = lsp.lsp_conf
|
||||
}
|
||||
use {
|
||||
'jose-elias-alvarez/null-ls.nvim',
|
||||
wants = 'plenary.nvim',
|
||||
after = 'nvim-lspconfig',
|
||||
config = lsp.null_ls_conf
|
||||
}
|
||||
use {
|
||||
'nanotee/sqls.nvim',
|
||||
ft = {'sql', 'mysql'},
|
||||
wants = 'nvim-lspconfig',
|
||||
config = lsp.sqls_conf
|
||||
}
|
||||
use {
|
||||
'folke/trouble.nvim',
|
||||
cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'},
|
||||
config = lsp.trouble_conf
|
||||
}
|
||||
use {
|
||||
'folke/todo-comments.nvim',
|
||||
wants = 'plenary.nvim',
|
||||
event = 'BufRead',
|
||||
config = lsp.comments_conf
|
||||
}
|
||||
use {
|
||||
'simrat39/symbols-outline.nvim',
|
||||
cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'},
|
||||
setup = lsp.outline_conf
|
||||
}
|
||||
use { -- TODO: config, scripts to install/update dap servers
|
||||
'rcarriga/nvim-dap-ui',
|
||||
keys = '<leader>d',
|
||||
wants = 'nvim-dap',
|
||||
requires = {{
|
||||
'mfussenegger/nvim-dap',
|
||||
config = lsp.dap_conf,
|
||||
opt = true
|
||||
}},
|
||||
config = lsp.dapui_conf
|
||||
}
|
||||
end
|
||||
|
||||
-- Completion
|
||||
local completion = require('modules.completion')
|
||||
local completion_plugins = function(use)
|
||||
use {
|
||||
'hrsh7th/nvim-cmp',
|
||||
event = 'InsertEnter',
|
||||
wants = {'LuaSnip', 'cmp-under-comparator'},
|
||||
requires = {
|
||||
{
|
||||
'L3MON4D3/LuaSnip',
|
||||
wants = 'friendly-snippets',
|
||||
requires = {{'rafamadriz/friendly-snippets', opt = true}},
|
||||
config = completion.snippets_conf,
|
||||
opt = true
|
||||
},
|
||||
{'lukas-reineke/cmp-under-comparator', opt = true}
|
||||
},
|
||||
config = completion.cmp_conf
|
||||
}
|
||||
use {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp'}
|
||||
use {'hrsh7th/cmp-path', after = 'nvim-cmp'}
|
||||
use {'hrsh7th/cmp-buffer', after = 'nvim-cmp'}
|
||||
use {'hrsh7th/cmp-calc', after = 'nvim-cmp'}
|
||||
use {'uga-rosa/cmp-dictionary', after = 'nvim-cmp'}
|
||||
use {'hrsh7th/cmp-nvim-lsp', after = {'nvim-cmp', 'nvim-lspconfig'}}
|
||||
-- use {
|
||||
-- 'tzachar/cmp-tabnine',
|
||||
-- after = 'nvim-cmp',
|
||||
-- run = './install.sh',
|
||||
-- config = completion.tabnine_conf
|
||||
-- }
|
||||
use {'kdheepak/cmp-latex-symbols', after = 'nvim-cmp'}
|
||||
use {'PaterJason/cmp-conjure', after = {'conjure', 'nvim-cmp'}}
|
||||
use {
|
||||
'windwp/nvim-autopairs',
|
||||
after = 'nvim-cmp',
|
||||
config = completion.autopairs_conf
|
||||
}
|
||||
end
|
||||
|
||||
-- Other tools
|
||||
local tools = require('modules.tools')
|
||||
local tools_plugins = function(use)
|
||||
use { -- TODO: check out fzf-lua
|
||||
'nvim-telescope/telescope.nvim',
|
||||
keys = '<leader>fj',
|
||||
cmd = 'Telescope',
|
||||
wants = {
|
||||
'popup.nvim',
|
||||
'plenary.nvim',
|
||||
'nvim-notify',
|
||||
'yabs.nvim',
|
||||
'telescope-symbols.nvim',
|
||||
'telescope-project.nvim',
|
||||
'telescope-fzf-native.nvim'
|
||||
},
|
||||
requires = {
|
||||
{'FollieHiyuki/telescope-symbols.nvim', opt = true},
|
||||
{'nvim-telescope/telescope-project.nvim', opt = true},
|
||||
{'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = true}
|
||||
},
|
||||
config = tools.telescope_conf
|
||||
}
|
||||
use { -- TODO: colors + config
|
||||
'pwntester/octo.nvim',
|
||||
cmd = 'Octo',
|
||||
wants = 'telescope.nvim',
|
||||
config = tools.octo_conf
|
||||
}
|
||||
use {
|
||||
'TimUntersberger/neogit',
|
||||
cmd = 'Neogit',
|
||||
wants = {'diffview.nvim', 'plenary.nvim'},
|
||||
requires = {{
|
||||
'sindrets/diffview.nvim',
|
||||
cmd = {
|
||||
'DiffviewOpen','DiffviewClose',
|
||||
'DiffviewToggleFiles', 'DiffviewFocusFiles'
|
||||
},
|
||||
config = tools.diffview_conf,
|
||||
opt = true
|
||||
}},
|
||||
config = tools.neogit_conf
|
||||
}
|
||||
use {
|
||||
'pianocomposer321/yabs.nvim',
|
||||
cmd = {'YabsTask', 'YabsDefaultTask'},
|
||||
config = tools.yabs_conf
|
||||
}
|
||||
use { -- TODO: check out kat0h/bufpreview.vim
|
||||
'iamcco/markdown-preview.nvim',
|
||||
run = 'cd app && yarn install',
|
||||
ft = {'markdown', 'rmd'},
|
||||
config = tools.markdown_preview_conf
|
||||
}
|
||||
use {
|
||||
'turbio/bracey.vim',
|
||||
run = 'npm install --prefix server',
|
||||
cmd = 'Bracey'
|
||||
}
|
||||
use {
|
||||
'windwp/nvim-spectre',
|
||||
keys = '<leader>p',
|
||||
wants = 'plenary.nvim',
|
||||
config = tools.spectre_conf
|
||||
}
|
||||
use {
|
||||
'echuraev/translate-shell.vim',
|
||||
cmd = {'Trans', 'TransSelectDirection'},
|
||||
config = tools.translate_conf
|
||||
}
|
||||
use {
|
||||
'mbbill/undotree',
|
||||
cmd = 'UndotreeToggle',
|
||||
setup = tools.undotree_conf
|
||||
}
|
||||
use {
|
||||
'akinsho/toggleterm.nvim',
|
||||
cmd = 'ToggleTerm',
|
||||
config = tools.toggleterm_conf
|
||||
}
|
||||
use {
|
||||
'michaelb/sniprun',
|
||||
run = 'cargo build --release',
|
||||
cmd = 'SnipRun',
|
||||
wants = 'nvim-notify',
|
||||
config = tools.sniprun_conf
|
||||
}
|
||||
use {
|
||||
'NTBBloodbath/rest.nvim',
|
||||
keys = {'<Plug>RestNvim', '<Plug>RestNvimPreview', '<Plug>RestNvimLast'},
|
||||
wants = {'plenary.nvim', 'nvim-treesitter'},
|
||||
config = tools.rest_conf
|
||||
}
|
||||
use { -- TODO: check out auto-session + session-lens
|
||||
'folke/persistence.nvim',
|
||||
event = 'BufReadPre',
|
||||
keys = '<leader>s',
|
||||
config = tools.session_conf
|
||||
}
|
||||
use {
|
||||
'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 {
|
||||
'chipsenkbeil/distant.nvim',
|
||||
cmd = {'DistantInstall', 'DistantLaunch'},
|
||||
config = tools.distant_conf
|
||||
}
|
||||
use {
|
||||
'rcarriga/nvim-notify',
|
||||
module = 'nvim-notify',
|
||||
config = tools.notify_conf
|
||||
}
|
||||
use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking
|
||||
end
|
||||
|
||||
-- Merge everything together
|
||||
local summary = function(use)
|
||||
needed_plugins(use)
|
||||
ui_plugins(use)
|
||||
editor_plugins(use)
|
||||
lsp_plugins(use)
|
||||
completion_plugins(use)
|
||||
tools_plugins(use)
|
||||
|
||||
-- Install plugins if missing
|
||||
packer.install()
|
||||
end
|
||||
|
||||
return packer.startup(summary)
|
||||
return M
|
||||
|
|
|
@ -325,10 +325,10 @@ function M.highlight_plugins()
|
|||
cmd('hi! link EftSubChar LineNr')
|
||||
|
||||
-- dashboard-nvim / alpha-nvim
|
||||
hi('DashboardHeader' , c.blue , '', 'bold' , '')
|
||||
hi('DashboardCenter' , c.green , '', 'bold' , '')
|
||||
hi('DashboardShortcut', c.grey_bright, '', 'bold,italic', '')
|
||||
hi('DashboardFooter' , c.purple , '', 'bold' , '')
|
||||
hi('DashboardHeader' , c.blue , '', 'bold' , '')
|
||||
hi('DashboardCenter' , c.green , '', 'bold' , '')
|
||||
hi('DashboardShortcut', c.purple, '', 'bold,italic', '')
|
||||
hi('DashboardFooter' , c.yellow, '', 'bold' , '')
|
||||
|
||||
-- symbols-outline.nvim
|
||||
hi('FocusedSymbol', c.yellow, '', 'bold', '')
|
||||
|
@ -427,9 +427,9 @@ function M.highlight_plugins()
|
|||
cmd('hi! link DiagnosticWarning LspDiagnosticsDefaultWarning')
|
||||
cmd('hi! link DiagnosticInformation LspDiagnosticsDefaultInformation')
|
||||
cmd('hi! link DiagnosticHint LspDiagnosticsDefaultHint')
|
||||
hi('LspSagaDiagnosticBorder', c.purple, '', '', '')
|
||||
hi('LspSagaDiagnosticHeader', c.yellow, '', 'bold', '')
|
||||
hi('LspSagaDiagnosticTruncateLine', c.purple, '', '', '')
|
||||
hi('LspSagaDiagnosticBorder', c.fg, '', '', '')
|
||||
hi('LspSagaDiagnosticHeader', c.blue, '', 'bold', '')
|
||||
hi('LspSagaDiagnosticTruncateLine', c.fg, '', '', '')
|
||||
cmd('hi! link LspSagaDiagnosticFloatingError LspDiagnosticsDefaultError')
|
||||
cmd('hi! link LspSagaDiagnosticFloatingWarn LspDiagnosticsDefaultWarning')
|
||||
cmd('hi! link LspSagaDiagnosticFloatingInfor LspDiagnosticsDefaultInformation')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
local M = {}
|
||||
local cmd = vim.api.nvim_command
|
||||
|
||||
function M.highlight(group, guifg, guibg, attr, guisp)
|
||||
local fg = guifg ~= '' and 'guifg=' .. guifg or 'guifg=NONE'
|
||||
|
@ -6,83 +7,18 @@ function M.highlight(group, guifg, guibg, attr, guisp)
|
|||
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)
|
||||
cmd('hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp)
|
||||
end
|
||||
|
||||
function M.lsp_on_attach(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
local lsp_mappings = {
|
||||
g = {
|
||||
d = {':lua vim.lsp.buf.definition()<CR>', 'Goto definition'},
|
||||
D = {':lua vim.lsp.buf.declaration()<CR>', 'Goto declaration'},
|
||||
i = {':Lspsaga implement<CR>', 'Implementations'},
|
||||
I = {':Telescope lsp_implementations<CR>', 'Implementations (Telescope)'},
|
||||
r = {':TroubleToggle lsp_references<CR>', 'References'},
|
||||
R = {':Telescope lsp_references<CR>', 'References (Telescope)'}
|
||||
},
|
||||
K = {':Lspsaga hover_doc<CR>', 'Hover doc'},
|
||||
['[d'] = {':Lspsaga diagnostic_jump_prev<CR>', 'Previous diagnostics'},
|
||||
[']d'] = {':Lspsaga diagnostic_jump_next<CR>', 'Next diagnostics'}
|
||||
}
|
||||
local lsp_leader_mappings = {
|
||||
l = {
|
||||
name = 'LSP',
|
||||
a = {':lua vim.lsp.buf.add_workspace_folder()<CR>', 'Add workspace folder'},
|
||||
b = {':TroubleToggle lsp_document_diagnostics<CR>', 'Buffer diagnostics'},
|
||||
B = {':Telescope lsp_document_diagnostics<CR>', 'Buffer diagnostics (Telescope)'},
|
||||
c = {':Lspsaga code_action<CR>', 'Code action'},
|
||||
C = {':Telescope lsp_code_actions<CR>', 'Code action (Telescope)'},
|
||||
d = {':TroubleToggle lsp_definitions<CR>', 'Definitions'},
|
||||
D = {':Telescope lsp_definitions<CR>', 'Definitions (Telescope)'},
|
||||
e = {':Lspsaga show_line_diagnostics<CR>', 'Line diagnostics'},
|
||||
f = {':Lspsaga lsp_finder<CR>', 'Finder'},
|
||||
g = {':SymbolsOutline<CR>', 'Symbol outline'},
|
||||
i = {':LspInfo<CR>', 'Lsp info'},
|
||||
l = {':TroubleToggle loclist<CR>', 'Diagnostics loclist'},
|
||||
n = {':Lspsaga rename<CR>', 'Rename'},
|
||||
p = {':Lspsaga preview_definition<CR>', 'Preview definition'},
|
||||
r = {':lua vim.lsp.buf.remove_workspace_folder()<CR>', 'Remove workspace folder'},
|
||||
s = {':Telescope lsp_document_symbols<CR>', 'Buffer symbols'},
|
||||
S = {':Telescope lsp_workspace_symbols<CR>', 'Workspace symbols'},
|
||||
t = {':TroubleToggle<CR>', 'Toggle Trouble'},
|
||||
w = {':TroubleToggle lsp_workspace_diagnostics<CR>', 'Workspace diagnostics'},
|
||||
W = {':Telescope lsp_workspace_diagnostics<CR>', 'Workspace diagnostics (Telescope)'},
|
||||
x = {':lua vim.lsp.buf.signature_help()<CR>', 'Signature help'},
|
||||
y = {':lua vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders()), vim.log.levels.INFO)<CR>', 'List workspace folders'}
|
||||
}
|
||||
}
|
||||
local lsp_visual_mappings = {
|
||||
l = {
|
||||
name = 'LSP',
|
||||
c = {':<C-U>Lspsaga range_code_action<CR>', 'Range code action'},
|
||||
C = {':Telescope lsp_range_code_actions<CR>', 'Range code action (Telescope)'}
|
||||
}
|
||||
}
|
||||
|
||||
local wk = require('which-key')
|
||||
wk.register(lsp_mappings, {buffer = bufnr})
|
||||
wk.register(lsp_leader_mappings, {buffer = bufnr, prefix = '<leader>'})
|
||||
wk.register(lsp_visual_mappings, {buffer = bufnr, prefix = '<leader>', mode = 'v'})
|
||||
|
||||
local opts = {noremap = true, silent = true}
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-f>', ':lua require("lspsaga.action").smart_scroll_with_saga(1)<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-b>', ':lua require("lspsaga.action").smart_scroll_with_saga(-1)<CR>', opts)
|
||||
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
wk.register({
|
||||
['lo'] = {':lua vim.lsp.buf.formatting()<CR>', 'Format buffer'}
|
||||
}, {buffer = bufnr, prefix = '<leader>'})
|
||||
-- vim.api.nvim_command('autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()')
|
||||
elseif client.resolved_capabilities.document_range_formatting then
|
||||
wk.register({
|
||||
['lo'] = {':lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})<CR>', 'Format buffer'}
|
||||
}, {buffer = bufnr, prefix = '<leader>'})
|
||||
wk.register({
|
||||
['lo'] = {':lua vim.lsp.buf.range_formatting()<CR>', 'Format range'}
|
||||
}, {buffer = bufnr, prefix = '<leader>', mode = 'v'})
|
||||
-- vim.api.nvim_command('autocmd BufWritePre <buffer> lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})')
|
||||
function M.load_autocmd(definitions)
|
||||
for group_name, definition in pairs(definitions) do
|
||||
cmd('augroup ' .. group_name)
|
||||
cmd('autocmd!')
|
||||
for _, def in ipairs(definition) do
|
||||
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
|
||||
cmd(command)
|
||||
end
|
||||
cmd('augroup END')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lint/autopep8"
|
||||
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||
|
||||
python3 -m venv ${server_path}/venv
|
||||
${server_path}/venv/bin/pip3 install -U pip
|
||||
${server_path}/venv/bin/pip3 install -U autopep8
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lint/black"
|
||||
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||
|
||||
python3 -m venv ${server_path}/venv
|
||||
${server_path}/venv/bin/pip3 install -U pip
|
||||
${server_path}/venv/bin/pip3 install -U black
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lint/flake8"
|
||||
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||
|
||||
python3 -m venv ${server_path}/venv
|
||||
${server_path}/venv/bin/pip3 install -U pip
|
||||
${server_path}/venv/bin/pip3 install -U flake8
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lint/isort"
|
||||
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||
|
||||
python3 -m venv ${server_path}/venv
|
||||
${server_path}/venv/bin/pip3 install -U pip
|
||||
${server_path}/venv/bin/pip3 install -U isort
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lint/pylint"
|
||||
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||
|
||||
python3 -m venv ${server_path}/venv
|
||||
${server_path}/venv/bin/pip3 install -U pip
|
||||
${server_path}/venv/bin/pip3 install -U pylint
|
|
@ -1,9 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This iss not spellings goor
|
||||
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lint/yapf"
|
||||
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||
|
||||
python3 -m venv ${server_path}/venv
|
||||
${server_path}/venv/bin/pip3 install -U pip
|
||||
${server_path}/venv/bin/pip3 install -U yapf
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/pylsp"
|
||||
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||
|
||||
python3 -m venv ${server_path}/venv
|
||||
${server_path}/venv/bin/pip3 install -U pip
|
||||
${server_path}/venv/bin/pip3 install -U 'python-lsp-server[all]'
|
||||
# ${server_path}/venv/bin/pip3 install -U pyls-flake8
|
||||
# ${server_path}/venv/bin/pip3 install -U pylsp-mypy
|
||||
# ${server_path}/venv/bin/pip3 install -U pyls-isort
|
||||
# ${server_path}/venv/bin/pip3 install -U pyls-memestra
|
||||
# ${server_path}/venv/bin/pip3 install -U pylsp-rope
|
||||
# ${server_path}/venv/bin/pip3 install -U python-lsp-black
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
current_path="$PWD"
|
||||
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/pyright"
|
||||
|
||||
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||
cd ${server_path}
|
||||
|
||||
[ ! -f package.json ] && npm init -y --scope=lsp || true
|
||||
npm install pyright@latest
|
||||
|
||||
cd ${current_path}
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
source ${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/pylsp/venv/bin/activate
|
||||
exec pylsp
|
Loading…
Reference in New Issue