Keybindings and smaller ui related improvements
Options: - lualine shows path of files - added breadcrumbs to programming buffers as winbar Plugins: - added mrcjkb/rustaceanvim for improved rust support - added lewis6991/gitsigns.nvim to show changes in files - dropped lspkind, it had no visible effect and could not easily be fixed - added j-hui/fidget.nvim to make $/progress messages (e.g. from lsp) visible Keybindings: - dropped unused and commented out keybindings - <leader>fr to resume last fzf search - <C-W>0, 1, 2, 3 to mimic emacs <C-x>.... window keys - <esc><esc> to clear last search - added desc field to many keybindings in lsp
This commit is contained in:
45
lua/lsp.lua
45
lua/lsp.lua
@@ -13,7 +13,7 @@ require('mason-lspconfig').setup({
|
||||
ensure_installed = {
|
||||
'pylsp',
|
||||
'lua_ls',
|
||||
'rust_analyzer',
|
||||
-- 'rust_analyzer', -- handled by rust mrcjkb/rustaceanvim
|
||||
'yamlls',
|
||||
'ts_ls',
|
||||
'gopls',
|
||||
@@ -22,45 +22,33 @@ require('mason-lspconfig').setup({
|
||||
},
|
||||
})
|
||||
|
||||
-- Customized on_attach function
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, { noremap = true, silent = true, desc = "Popup diagnostics" })
|
||||
-- 2024-09-23 - currently unused
|
||||
-- vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
-- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "LSP show signature", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder,
|
||||
{ desc = "Workspace add folder", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder,
|
||||
{ desc = "Workspace remove folder", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
-- vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||
-- vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||
end, { desc = "Workspace list folders", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, { desc = "LSP Rename", unpack(bufopts) })
|
||||
vim.keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, bufopts)
|
||||
end, { desc = "LSP Format buffer", unpack(bufopts) })
|
||||
|
||||
-- 2024-09-09 - some ccflow commands
|
||||
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<space>d', fzf.diagnostics_document, { desc = "Document diagnostics" })
|
||||
vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" })
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, { desc = "Popup diagnostics" })
|
||||
vim.keymap.set('n', '<space>s', fzf.lsp_document_symbols, { desc = "Doc symbols" })
|
||||
vim.keymap.set('n', '<space>c', fzf.lsp_code_actions, { desc = "Code Actions" })
|
||||
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
@@ -69,7 +57,7 @@ local on_attach = function(client, bufnr)
|
||||
end
|
||||
|
||||
-- Set different settings for different languages' LSP
|
||||
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
|
||||
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
|
||||
-- - the settings table is sent to the LSP
|
||||
-- - on_attach: a lua callback function to run after LSP attaches to a given buffer
|
||||
@@ -108,3 +96,12 @@ require('mason-lspconfig').setup_handlers({
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- use on_attach to get lsp related shortcuts
|
||||
vim.g.rustaceanvim = {
|
||||
-- LSP configuration
|
||||
server = {
|
||||
on_attach = on_attach
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user