feat(diagnostics): add min severity level for v text, cleaner mappings
This commit is contained in:
parent
0d758652e5
commit
6dc398b060
4 changed files with 36 additions and 26 deletions
|
@ -80,12 +80,13 @@ require('telescope').setup({
|
|||
lsp_document_diagnostics = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'cursor',
|
||||
layout_strategy = 'vertical',
|
||||
prompt_title = 'Diagnostics',
|
||||
results_title = '',
|
||||
layout_config = {
|
||||
width = 0.5,
|
||||
height = 0.5,
|
||||
prompt_position = 'top'
|
||||
},
|
||||
mappings = mappings,
|
||||
},
|
||||
|
|
|
@ -32,7 +32,7 @@ function M.init()
|
|||
highlight('TelescopeSelectionCaret', 'None', colors.selection_caret)
|
||||
|
||||
-- autocomplete highlights
|
||||
highlight('CmpItemAbbrDeprecated', colors.warn)
|
||||
highlight('CmpItemAbbrDeprecated', 'None', colors.warn)
|
||||
|
||||
-- todo: needs to highlight after lsp start, why? idk
|
||||
vim.cmd([[
|
||||
|
|
|
@ -8,15 +8,24 @@ function M.init()
|
|||
virtual_text = {
|
||||
spacing = 4,
|
||||
source = 'always',
|
||||
-- severity = 'error'
|
||||
-- prefix = '👾',
|
||||
severity = {
|
||||
min = vim.diagnostic.severity.HINT,
|
||||
},
|
||||
-- todo: icons for diagnostics?
|
||||
--[[ format = function(diagnostic)
|
||||
if diagnostic.severity == vim.diagnostic.severity.ERROR then
|
||||
return string.format('E: %s', diagnostic.message)
|
||||
end
|
||||
return diagnostic.message
|
||||
end, ]]
|
||||
},
|
||||
signs = true,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
show_header = true,
|
||||
source = 'always',
|
||||
}
|
||||
border = 'single',
|
||||
},
|
||||
})
|
||||
|
||||
local function do_diagnostic_signs()
|
||||
|
|
|
@ -4,30 +4,30 @@ local map = require('cosmic.utils').map
|
|||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
map('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
map('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
map('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
map('n', 'gr', '<cmd>lua require("telescope.builtin").lsp_references()<CR>', opts)
|
||||
map('n', 'gn', '<cmd>lua require("cosmic.core.theme.ui").rename()<CR>', opts)
|
||||
map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
|
||||
map('n', 'gd', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
|
||||
map('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
|
||||
map('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
|
||||
map('n', 'gr', '<cmd>lua require("telescope.builtin").lsp_references()<cr>', opts)
|
||||
map('n', 'gn', '<cmd>lua require("cosmic.core.theme.ui").rename()<cr>', opts)
|
||||
|
||||
-- diagnostics
|
||||
map('n', '[g', '<cmd>lua vim.diagnostic.goto_prev({ float = { border = "single" }})<CR>', opts)
|
||||
map('n', ']g', '<cmd>lua vim.diagnostic.goto_next({ float = { border = "single" }})<CR>', opts)
|
||||
map('n', 'ge', '<cmd>lua vim.diagnostic.open_float(0, { scope = "line", border = "single" })<CR>', opts)
|
||||
map('n', '<space>ge', ':Telescope lsp_document_diagnostics<CR>', opts)
|
||||
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
map('n', '<space>ga', '<cmd>lua require("telescope.builtin").lsp_code_actions()<CR>', opts)
|
||||
map('v', '<space>ga', '<cmd>lua require("telescope.builtin").lsp_range_code_actions()<CR>', opts)
|
||||
map('n', '<space>gf', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
map('n', '<C-k>', '<cmd>lua require("lsp_signature").signature()<CR>', opts)
|
||||
map('n', '[g', '<cmd>lua vim.diagnostic.goto_prev({ float = { show_header = false }})<cr>', opts)
|
||||
map('n', ']g', '<cmd>lua vim.diagnostic.goto_next({ float = { show_header = false }})<cr>', opts)
|
||||
map('n', 'ge', '<cmd>lua vim.diagnostic.open_float(0, { scope = "line", })<cr>', opts)
|
||||
map('n', '<space>ge', ':telescope lsp_document_diagnostics<cr>', opts)
|
||||
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
|
||||
map('n', '<space>ga', '<cmd>lua require("telescope.builtin").lsp_code_actions()<cr>', opts)
|
||||
map('v', '<space>ga', '<cmd>lua require("telescope.builtin").lsp_range_code_actions()<cr>', opts)
|
||||
map('n', '<space>gf', '<cmd>lua vim.lsp.buf.formatting()<cr>', opts)
|
||||
map('n', '<C-K>', '<cmd>lua require("lsp_signature").signature()<cr>', opts)
|
||||
|
||||
-- lsp workspace
|
||||
map('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
map('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
map('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
map('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>', opts)
|
||||
map('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>', opts)
|
||||
map('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>', opts)
|
||||
|
||||
-- typescript helpers
|
||||
map('n', '<space>gr', ':TSLspRenameFile<CR>', opts)
|
||||
map('n', '<space>go', ':TSLspOrganize<CR>', opts)
|
||||
map('n', '<space>gi', ':TSLspImportAll<CR>', opts)
|
||||
map('n', '<space>gr', ':tslsprenamefile<cr>', opts)
|
||||
map('n', '<space>go', ':tslsporganize<cr>', opts)
|
||||
map('n', '<space>gi', ':tslspimportall<cr>', opts)
|
||||
|
|
Loading…
Add table
Reference in a new issue