Better lsp keybinds
This commit is contained in:
parent
9140244aa2
commit
33f5805bee
@ -1,32 +0,0 @@
|
|||||||
{
|
|
||||||
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
|
|
||||||
"LuaSnip": { "branch": "master", "commit": "80a8528f084a97b624ae443a6f50ff8074ba486b" },
|
|
||||||
"cmp-async-path": { "branch": "main", "commit": "d8229a93d7b71f22c66ca35ac9e6c6cd850ec61d" },
|
|
||||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
|
||||||
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
|
|
||||||
"cmp-git": { "branch": "main", "commit": "f900a4cf117300fdc3ba31d26f8b6223ccd9c574" },
|
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
|
|
||||||
"cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f0f53f704c08ea501f9d222b23491b0d354644b0" },
|
|
||||||
"cmp-treesitter": { "branch": "master", "commit": "b8bc760dfcc624edd5454f0982b63786a822eed9" },
|
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
|
||||||
"gruvbox.nvim": { "branch": "main", "commit": "477c62493c82684ed510c4f70eaf83802e398898" },
|
|
||||||
"lazy.nvim": { "branch": "main", "commit": "16603c6917435d8446f7357cb61095138a417085" },
|
|
||||||
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" },
|
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "40301e1c74bc0946eece13edf2b1c561cc497491" },
|
|
||||||
"mason-null-ls.nvim": { "branch": "main", "commit": "ae0c5fa57468ac65617f1bf821ba0c3a1e251f0c" },
|
|
||||||
"mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" },
|
|
||||||
"null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
|
|
||||||
"nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" },
|
|
||||||
"nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" },
|
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "d0467b9574b48429debf83f8248d8cee79562586" },
|
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "a8c14d68b024ffc20baec92d1acc91796bcfb485" },
|
|
||||||
"nvim-treesitter-context": { "branch": "master", "commit": "2806d83e3965017382ce08792ee527e708fa1bd4" },
|
|
||||||
"nvim-ts-rainbow2": { "branch": "master", "commit": "b3120cd5ae9ca524af9cb602f41e12e301fa985f" },
|
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "5de460ca7595806044eced31e3c36c159a493857" },
|
|
||||||
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
|
|
||||||
"range-highlight.nvim": { "branch": "master", "commit": "8b5e8ccb3460b2c3675f4639b9f54e64eaab36d9" },
|
|
||||||
"tagbar": { "branch": "master", "commit": "5d6990e4fc5b3e3b88a3af90146f2561c4f6d828" },
|
|
||||||
"telescope.nvim": { "branch": "master", "commit": "4522d7e3ea75ffddabdc39957168a8a7060b5df0" },
|
|
||||||
"vim-matchup": { "branch": "master", "commit": "6dbe108230c7dbbf00555b7d4d9f6a891837ef07" },
|
|
||||||
"vim-sandwich": { "branch": "master", "commit": "c5a2cc438ce6ea2005c556dc833732aa53cae21a" }
|
|
||||||
}
|
|
@ -10,12 +10,14 @@ if not vim.loop.fs_stat(lazypath) then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
opts = {
|
|
||||||
|
local opts = {
|
||||||
install = {
|
install = {
|
||||||
colorscheme = { "gruvbox" }
|
colorscheme = { "gruvbox" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require("lazy").setup({
|
|
||||||
|
local plugins = {
|
||||||
{
|
{
|
||||||
"ellisonleao/gruvbox.nvim",
|
"ellisonleao/gruvbox.nvim",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
@ -109,7 +111,13 @@ require("lazy").setup({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"machakann/vim-sandwich",
|
"machakann/vim-sandwich",
|
||||||
"numToStr/Comment.nvim",
|
{
|
||||||
|
"numToStr/Comment.nvim",
|
||||||
|
event = "BufEnter",
|
||||||
|
config = function ()
|
||||||
|
require("Comment").setup()
|
||||||
|
end
|
||||||
|
},
|
||||||
"andymass/vim-matchup",
|
"andymass/vim-matchup",
|
||||||
{
|
{
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
@ -126,4 +134,23 @@ require("lazy").setup({
|
|||||||
"winston0410/range-highlight.nvim",
|
"winston0410/range-highlight.nvim",
|
||||||
event = "CmdlineEnter"
|
event = "CmdlineEnter"
|
||||||
}
|
}
|
||||||
}, opts)
|
}
|
||||||
|
|
||||||
|
local vscode_plugins = {
|
||||||
|
"machakann/vim-sandwich",
|
||||||
|
{
|
||||||
|
"numToStr/Comment.nvim",
|
||||||
|
event = "BufEnter",
|
||||||
|
config = function ()
|
||||||
|
require("Comment").setup()
|
||||||
|
end
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if vim.g.vscode then
|
||||||
|
-- VSCode extension
|
||||||
|
require("lazy").setup(vscode_plugins, opts)
|
||||||
|
else
|
||||||
|
-- ordinary Neovim
|
||||||
|
require("lazy").setup(plugins, opts)
|
||||||
|
end
|
||||||
|
@ -2,10 +2,10 @@ local map = vim.api.nvim_set_keymap
|
|||||||
|
|
||||||
-- vscode
|
-- vscode
|
||||||
if vim.g.vscode then
|
if vim.g.vscode then
|
||||||
-- undo/REDO via vscode
|
-- undo/REDO via vscode
|
||||||
map("n","u","<Cmd>call VSCodeNotify('undo')<CR>", {})
|
map("n", "u", "<Cmd>call VSCodeNotify('undo')<CR>", {})
|
||||||
map("n","<C-r>","<Cmd>call VSCodeNotify('redo')<CR>", {})
|
map("n", "<C-r>", "<Cmd>call VSCodeNotify('redo')<CR>", {})
|
||||||
map("n","gf", "<Cmd>call VSCodeCall('editor.action.openLink')<CR>", {silent = true, noremap = true})
|
map("n", "gf", "<Cmd>call VSCodeCall('editor.action.openLink')<CR>", { silent = true, noremap = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- generic mappings
|
-- generic mappings
|
||||||
@ -39,22 +39,9 @@ map('i', '?', '?<c-g>u', { noremap = true })
|
|||||||
-- plugin mappings
|
-- plugin mappings
|
||||||
-- gitsigns
|
-- gitsigns
|
||||||
map('', '<leader>gs', ':Gitsigns toggle_signs<cr>', { silent = true })
|
map('', '<leader>gs', ':Gitsigns toggle_signs<cr>', { silent = true })
|
||||||
-- lsp stuff
|
|
||||||
map('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>',
|
|
||||||
{ silent = false, noremap = true })
|
|
||||||
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', { noremap = true })
|
|
||||||
map('', '<leader>K', '<cmd>lua vim.diagnostic.open_float()<CR>',
|
|
||||||
{ noremap = true })
|
|
||||||
map('', '<leader>qf',
|
|
||||||
'<cmd>lua vim.diagnostic.setqflist({open = false})<cr><cmd>Telescope quickfix<cr>',
|
|
||||||
{ silent = true })
|
|
||||||
|
|
||||||
-- toggle tagbar
|
-- toggle tagbar
|
||||||
map('', '<leader>tt', ':TagbarToggle<cr>', { silent = true })
|
map('', '<leader>tt', ':TagbarToggle<cr>', { silent = true })
|
||||||
|
|
||||||
-- toggle formatter
|
|
||||||
map('', '<leader>fm', ':lua vim.lsp.buf.format({async = true})<cr>', { silent = true })
|
|
||||||
|
|
||||||
-- toggle Hop
|
-- toggle Hop
|
||||||
map('', '<leader>b', ':HopWordBC<cr>', { silent = true })
|
map('', '<leader>b', ':HopWordBC<cr>', { silent = true })
|
||||||
map('', '<leader>w', ':HopWordAC<cr>', { silent = true })
|
map('', '<leader>w', ':HopWordAC<cr>', { silent = true })
|
||||||
|
@ -1,15 +1,52 @@
|
|||||||
require("mason").setup {ui = {icons = {package_installed = "✓"}}}
|
-- Global mappings.
|
||||||
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
||||||
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
|
||||||
|
|
||||||
|
-- Use LspAttach autocommand to only map the following keys
|
||||||
|
-- after the language server attaches to the current buffer
|
||||||
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||||
|
callback = function(ev)
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||||
|
|
||||||
|
-- Buffer local mappings.
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
local opts = { buffer = ev.buf }
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||||
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||||
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||||
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||||
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||||
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, opts)
|
||||||
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
||||||
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
|
||||||
|
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||||
|
vim.keymap.set('n', '<space>f', function()
|
||||||
|
vim.lsp.buf.format { async = true }
|
||||||
|
end, opts)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
require("mason").setup { ui = { icons = { package_installed = "✓" } } }
|
||||||
require("mason-lspconfig").setup {}
|
require("mason-lspconfig").setup {}
|
||||||
-- Dynamic loading of lsp servers
|
-- Dynamic loading of lsp servers
|
||||||
require("mason-lspconfig").setup_handlers {
|
require("mason-lspconfig").setup_handlers {
|
||||||
-- The first entry (without a key) will be the default handler
|
-- The first entry (without a key) will be the default handler
|
||||||
-- and will be called for each installed server that doesn't have
|
-- and will be called for each installed server that doesn't have
|
||||||
-- a dedicated handler.
|
-- a dedicated handler.
|
||||||
function(server_name) -- default handler (optional)
|
function(server_name) -- default handler (optional)
|
||||||
require("lspconfig")[server_name].setup {}
|
require("lspconfig")[server_name].setup {}
|
||||||
end,
|
end,
|
||||||
-- Next, you can provide targeted overrides for specific servers.
|
-- Next, you can provide targeted overrides for specific servers.
|
||||||
-- For example, a handler override for the `rust_analyzer`:
|
-- For example, a handler override for the `rust_analyzer`:
|
||||||
["rust_analyzer"] = function() require("rust-tools").setup {} end
|
["rust_analyzer"] = function() require("rust-tools").setup {} end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user