mirror of
https://git.disroot.org/FollieHiyuki/dotfiles.git
synced 2024-11-24 16:28:22 -05:00
neovim: clean up
mappings: add doc for nvim-treesitter mappings chore: unify the way mappings to a command is called nvim-treesitter: load vim.opt for folding after setup() nvim-lspconfig: emmet_ls is now officially supported upstream
This commit is contained in:
parent
d09754811c
commit
c196180d0a
@ -8,7 +8,7 @@ local function pandoc_convert(ofiletype)
|
|||||||
|
|
||||||
local ifilename = vim.fn.expand('%:p')
|
local ifilename = vim.fn.expand('%:p')
|
||||||
local ofilename = vim.fn.expand('%:p:r') .. '.' .. ofiletype
|
local ofilename = vim.fn.expand('%:p:r') .. '.' .. ofiletype
|
||||||
local cmd
|
local cmd = nil
|
||||||
|
|
||||||
if ofiletype == 'pdf' then
|
if ofiletype == 'pdf' then
|
||||||
cmd = string.format('pandoc %s -o %s --pdf-engine=xelatex -V "mainfont:Iosevka Etoile" -V "sansfont:Iosevka Aile" -V "monofont:Iosevka" -V "geometry:margin=1in"', ifilename, ofilename)
|
cmd = string.format('pandoc %s -o %s --pdf-engine=xelatex -V "mainfont:Iosevka Etoile" -V "sansfont:Iosevka Aile" -V "monofont:Iosevka" -V "geometry:margin=1in"', ifilename, ofilename)
|
||||||
@ -84,18 +84,34 @@ wk.register({
|
|||||||
['['] = {
|
['['] = {
|
||||||
name = 'Block motions (previous)',
|
name = 'Block motions (previous)',
|
||||||
d = 'Previous diagnostics',
|
d = 'Previous diagnostics',
|
||||||
g = 'Previous git hunk'
|
g = 'Previous git hunk',
|
||||||
|
m = 'Previous start of outer class',
|
||||||
|
M = 'Previous end of outer class',
|
||||||
|
['['] = 'Previous start of outer function',
|
||||||
|
[']'] = 'Previous end of outer function'
|
||||||
},
|
},
|
||||||
[']'] = {
|
[']'] = {
|
||||||
name = 'Block motions (next)',
|
name = 'Block motions (next)',
|
||||||
d = 'Next diagnostics',
|
d = 'Next diagnostics',
|
||||||
g = 'Next git hunk'
|
g = 'Next git hunk',
|
||||||
|
m = 'Next start of outer class',
|
||||||
|
M = 'Next end of outer class',
|
||||||
|
['['] = 'Next start of outer function',
|
||||||
|
[']'] = 'Next end of outer function'
|
||||||
},
|
},
|
||||||
g = {
|
g = {
|
||||||
name = 'Goto motions',
|
name = 'Goto motions',
|
||||||
|
c = {
|
||||||
|
name = 'Comment',
|
||||||
|
c = 'Current line'
|
||||||
|
},
|
||||||
d = 'Go to definition',
|
d = 'Go to definition',
|
||||||
D = 'Go to declaration',
|
D = 'Go to declaration',
|
||||||
i = 'Go to implementation',
|
i = 'Go to implementation',
|
||||||
|
n = {
|
||||||
|
name = 'Incremental selection',
|
||||||
|
i = 'Initialize selection'
|
||||||
|
},
|
||||||
r = 'Go to references',
|
r = 'Go to references',
|
||||||
R = {':TroubleToggle lsp_references<CR>', 'Reference list'}
|
R = {':TroubleToggle lsp_references<CR>', 'Reference list'}
|
||||||
},
|
},
|
||||||
@ -122,6 +138,31 @@ wk.register({
|
|||||||
['<A-s>'] = {':HopPattern<CR>', 'Hop to pattern'}
|
['<A-s>'] = {':HopPattern<CR>', 'Hop to pattern'}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-----------------
|
||||||
|
-- Visual mode --
|
||||||
|
-----------------
|
||||||
|
wk.register({
|
||||||
|
a = {
|
||||||
|
c = 'Outer class',
|
||||||
|
f = 'Outer function'
|
||||||
|
},
|
||||||
|
|
||||||
|
i = {
|
||||||
|
c = 'Inner class',
|
||||||
|
f = 'Inner function'
|
||||||
|
},
|
||||||
|
|
||||||
|
g = {
|
||||||
|
c = 'Comment',
|
||||||
|
n = {
|
||||||
|
name = 'Incremental selection',
|
||||||
|
n = 'Increment node',
|
||||||
|
s = 'Increment scope',
|
||||||
|
m = 'Decrement node'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {mode = 'v'})
|
||||||
|
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
-- Normal mode (with leader key) --
|
-- Normal mode (with leader key) --
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
@ -52,9 +52,6 @@ end
|
|||||||
-- end
|
-- end
|
||||||
|
|
||||||
function M.treesitter_conf()
|
function M.treesitter_conf()
|
||||||
vim.api.nvim_command('set foldmethod=expr')
|
|
||||||
vim.api.nvim_command('set foldexpr=nvim_treesitter#foldexpr()')
|
|
||||||
|
|
||||||
-- Additional parser for rest.nvim (*.http files)
|
-- Additional parser for rest.nvim (*.http files)
|
||||||
local parser_configs = require('nvim-treesitter.parsers').get_parser_configs()
|
local parser_configs = require('nvim-treesitter.parsers').get_parser_configs()
|
||||||
parser_configs.http = {
|
parser_configs.http = {
|
||||||
@ -68,6 +65,16 @@ function M.treesitter_conf()
|
|||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
ensure_installed = 'maintained',
|
ensure_installed = 'maintained',
|
||||||
highlight = {enable = true},
|
highlight = {enable = true},
|
||||||
|
incremental_selection = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
init_selection = 'gni',
|
||||||
|
node_incremental = 'gnn',
|
||||||
|
scope_incremental = 'gns',
|
||||||
|
node_decremental = 'gnm'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
-- indent = {enable = true},
|
||||||
textobjects = {
|
textobjects = {
|
||||||
select = {
|
select = {
|
||||||
enable = true,
|
enable = true,
|
||||||
@ -102,6 +109,10 @@ function M.treesitter_conf()
|
|||||||
},
|
},
|
||||||
matchup = {enable = true}
|
matchup = {enable = true}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- tree-sitter based folding
|
||||||
|
vim.opt.foldmethod = 'expr'
|
||||||
|
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- function M.spellsitter_conf()
|
-- function M.spellsitter_conf()
|
||||||
|
@ -11,26 +11,26 @@ function M.lsp_conf()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local opts = {noremap = true, silent = true}
|
local opts = {noremap = true, silent = true}
|
||||||
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
buf_set_keymap('n', 'gD', ':lua vim.lsp.buf.declaration()<CR>', opts)
|
||||||
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
buf_set_keymap('n', 'gd', ':lua vim.lsp.buf.definition()<CR>', opts)
|
||||||
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
buf_set_keymap('n', 'K', ':lua vim.lsp.buf.hover()<CR>', opts)
|
||||||
buf_set_keymap('n', 'gi', '<Cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
buf_set_keymap('n', 'gi', ':lua vim.lsp.buf.implementation()<CR>', opts)
|
||||||
buf_set_keymap('n', '<leader>lx', '<Cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
buf_set_keymap('n', '<leader>lx', ':lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||||
buf_set_keymap('n', '<leader>la', '<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
buf_set_keymap('n', '<leader>la', ':lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||||
buf_set_keymap('n', '<leader>lr', '<Cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
buf_set_keymap('n', '<leader>lr', ':lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||||
buf_set_keymap('n', '<leader>lw', '<Cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
buf_set_keymap('n', '<leader>lw', ':lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||||
buf_set_keymap('n', '<leader>ld', '<Cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
buf_set_keymap('n', '<leader>ld', ':lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
buf_set_keymap('n', '<leader>ln', '<Cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
buf_set_keymap('n', '<leader>ln', ':lua vim.lsp.buf.rename()<CR>', opts)
|
||||||
buf_set_keymap('n', 'gr', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
|
buf_set_keymap('n', 'gr', ':lua vim.lsp.buf.references()<CR>', opts)
|
||||||
buf_set_keymap('n', '<leader>le', '<Cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
buf_set_keymap('n', '<leader>le', ':lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||||
buf_set_keymap('n', '[d', '<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
buf_set_keymap('n', '[d', ':lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||||
buf_set_keymap('n', ']d', '<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
buf_set_keymap('n', ']d', ':lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||||
buf_set_keymap('n', '<leader>ll', '<Cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
buf_set_keymap('n', '<leader>ll', ':lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||||
|
|
||||||
if client.resolved_capabilities.document_formatting then
|
if client.resolved_capabilities.document_formatting then
|
||||||
buf_set_keymap('n', '<leader>lo', '<Cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
buf_set_keymap('n', '<leader>lo', ':lua vim.lsp.buf.formatting()<CR>', opts)
|
||||||
elseif client.resolved_capabilities.document_range_formatting then
|
elseif client.resolved_capabilities.document_range_formatting then
|
||||||
buf_set_keymap('n', '<leader>lo', '<Cmd>lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})<CR>', opts)
|
buf_set_keymap('n', '<leader>lo', ':lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})<CR>', opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Attach lsp_signature.nvim
|
-- Attach lsp_signature.nvim
|
||||||
@ -190,19 +190,14 @@ function M.lsp_conf()
|
|||||||
-- }
|
-- }
|
||||||
|
|
||||||
-- Emmet
|
-- Emmet
|
||||||
if not lspconf.emmet_ls then
|
lspconf.emmet_ls.setup {
|
||||||
require('lspconfig/configs').emmet_ls = {
|
cmd = {servers_path .. '/emmet_ls/node_modules/.bin/emmet-ls', '--stdio'},
|
||||||
default_config = {
|
filetypes = {
|
||||||
cmd = {servers_path .. '/emmet_ls/node_modules/.bin/emmet-ls', '--stdio'},
|
'html', 'xml', 'css', 'scss', 'sass',
|
||||||
filetypes = {'html', 'css'},
|
'javascript', 'javascriptreact'
|
||||||
root_dir = function(fname)
|
},
|
||||||
return vim.loop.cwd()
|
capabilities = capabilities
|
||||||
end,
|
}
|
||||||
settings = {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
lspconf.emmet_ls.setup {capabilities = capabilities}
|
|
||||||
|
|
||||||
-- HTML
|
-- HTML
|
||||||
lspconf.html.setup {
|
lspconf.html.setup {
|
||||||
|
@ -146,9 +146,6 @@ function M.orgmode_conf()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.vimtex_conf()
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.spectre_conf()
|
function M.spectre_conf()
|
||||||
require('spectre').setup()
|
require('spectre').setup()
|
||||||
|
|
||||||
@ -201,7 +198,7 @@ function M.toggleterm_conf()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- function M.wilder_conf()
|
-- function M.wilder_conf()
|
||||||
-- vim.api.nvim_command [[ call wilder#setup({'modes': [':', '/', '?']}) ]]
|
-- vim.api.nvim_command [[call wilder#setup({'modes': [':', '/', '?']})]]
|
||||||
|
|
||||||
-- Doesn't work yet. Bugs in Neovim (see neovim/neovim#14809 and gelguy/wilder.nvim#53)
|
-- Doesn't work yet. Bugs in Neovim (see neovim/neovim#14809 and gelguy/wilder.nvim#53)
|
||||||
-- so can't do multi-line config inside vim.cmd [[ ]] with \
|
-- so can't do multi-line config inside vim.cmd [[ ]] with \
|
||||||
|
@ -456,19 +456,19 @@ function M.gitsigns_conf()
|
|||||||
-- Default keymap options
|
-- Default keymap options
|
||||||
noremap = true,
|
noremap = true,
|
||||||
|
|
||||||
['n ]g'] = {expr = true, '&diff ? \']g\' : \'<cmd>lua require"gitsigns.actions".next_hunk()<CR>\''},
|
['n ]g'] = {expr = true, '&diff ? \']g\' : \':lua require"gitsigns.actions".next_hunk()<CR>\''},
|
||||||
['n [g'] = {expr = true, '&diff ? \'[g\' : \'<cmd>lua require"gitsigns.actions".prev_hunk()<CR>\''},
|
['n [g'] = {expr = true, '&diff ? \'[g\' : \':lua require"gitsigns.actions".prev_hunk()<CR>\''},
|
||||||
|
|
||||||
['n <leader>gs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',
|
['n <leader>gs'] = ':lua require"gitsigns".stage_hunk()<CR>',
|
||||||
['v <leader>gs'] = '<cmd>lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
|
['v <leader>gs'] = ':lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
|
||||||
['n <leader>gu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
|
['n <leader>gu'] = ':lua require"gitsigns".undo_stage_hunk()<CR>',
|
||||||
['n <leader>gr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>',
|
['n <leader>gr'] = ':lua require"gitsigns".reset_hunk()<CR>',
|
||||||
['v <leader>gr'] = '<cmd>lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
|
['v <leader>gr'] = ':lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
|
||||||
['n <leader>gR'] = '<cmd>lua require"gitsigns".reset_buffer()<CR>',
|
['n <leader>gR'] = ':lua require"gitsigns".reset_buffer()<CR>',
|
||||||
['n <leader>gp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>',
|
['n <leader>gp'] = ':lua require"gitsigns".preview_hunk()<CR>',
|
||||||
['n <leader>gb'] = '<cmd>lua require"gitsigns".blame_line(true)<CR>',
|
['n <leader>gb'] = ':lua require"gitsigns".blame_line(true)<CR>',
|
||||||
['n <leader>gS'] = '<cmd>lua require"gitsigns".stage_buffer()<CR>',
|
['n <leader>gS'] = ':lua require"gitsigns".stage_buffer()<CR>',
|
||||||
['n <leader>gU'] = '<cmd>lua require"gitsigns".reset_buffer_index()<CR>',
|
['n <leader>gU'] = ':lua require"gitsigns".reset_buffer_index()<CR>',
|
||||||
|
|
||||||
-- Text objects
|
-- Text objects
|
||||||
['o ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>',
|
['o ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>',
|
||||||
|
@ -351,7 +351,7 @@ return packer.startup(function(use)
|
|||||||
run = 'npm install --prefix server',
|
run = 'npm install --prefix server',
|
||||||
cmd = 'Bracey'
|
cmd = 'Bracey'
|
||||||
}
|
}
|
||||||
use { -- shouldn't be lazy-loaded (global bindings don't work)
|
use { -- TODO: check out neorg
|
||||||
'kristijanhusak/orgmode.nvim',
|
'kristijanhusak/orgmode.nvim',
|
||||||
ft = 'org',
|
ft = 'org',
|
||||||
config = tools.orgmode_conf
|
config = tools.orgmode_conf
|
||||||
@ -400,7 +400,6 @@ return packer.startup(function(use)
|
|||||||
'NTBBloodbath/rest.nvim',
|
'NTBBloodbath/rest.nvim',
|
||||||
keys = {'<Plug>RestNvim', '<Plug>RestNvimPreview', '<Plug>RestNvimLast'},
|
keys = {'<Plug>RestNvim', '<Plug>RestNvimPreview', '<Plug>RestNvimLast'},
|
||||||
wants = {'plenary.nvim', 'nvim-treesitter'},
|
wants = {'plenary.nvim', 'nvim-treesitter'},
|
||||||
-- run = ':TSInstall http',
|
|
||||||
config = tools.rest_conf
|
config = tools.rest_conf
|
||||||
}
|
}
|
||||||
use {
|
use {
|
||||||
|
Loading…
Reference in New Issue
Block a user