config = /*lua*/ ''
vim.lsp.log.set_level("OFF")
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', function() vim.diagnostic.jump({ count=-1, float=true, severity = { min = vim.diagnostic.severity.WARN } }) end)
vim.keymap.set('n', ']d', function() vim.diagnostic.jump({ count= 1, float=true, severity = { min = vim.diagnostic.severity.WARN } }) end)
vim.keymap.set('n', '[D', function() vim.diagnostic.jump({ count=-1, float=true, severity = { min = vim.diagnostic.severity.INFO } }) end)
vim.keymap.set('n', ']D', function() vim.diagnostic.jump({ count= 1, float=true, severity = { min = vim.diagnostic.severity.INFO } }) end)
vim.keymap.set('n', '<space>d', function() Snacks.picker.diagnostics_buffer() end)
vim.keymap.set('n', '<space>D', function() Snacks.picker.diagnostics() end)
vim.diagnostic.config({
float = {
source = true, -- Show the source (LSP server name)
},
signs = {
text = {
-- Do not show 'H' in the sign/number column.
-- The main reason is harper_ls throws many hint diagnostics
[vim.diagnostic.severity.HINT] = "",
},
},
})
-- 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(_args)
vim.lsp.inlay_hint.enable(true, { bufnr = _args.buf })
-- gd is defined in ./ctags.nix; it tries LSP definitions, then falls back to ctags.
vim.keymap.set('n', 'gD', Snacks.picker.lsp_declarations)
vim.keymap.set('n', 'gt', Snacks.picker.lsp_type_definitions)
vim.keymap.set('n', 'gr', Snacks.picker.lsp_references)
vim.keymap.set('n', 'gi', Snacks.picker.lsp_implementations)
vim.keymap.set('n', 'K', vim.lsp.buf.hover)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename)
-- make sure lsp/vim native indent(share/nvim/runtime/indent/python.vim)
-- don't override my setting
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
end,
})
'';
}];
};
}