dotfiles-ansible/roles/nvim/files/nvim/lua/modules/lsp/config.lua

260 lines
8.8 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local M = {}
function M.signature()
require('lsp_signature').setup {
bind = true, -- This is mandatory, otherwise border config doesn't work
floating_window = true,
fix_pos = true,
hint_enable = false,
hint_prefix = '',
hint_scheme = 'String',
hi_parameter = 'Visual',
transparency = 5,
handler_opts = {border = 'single'},
zindex = 50, -- set to 200 to make the float window on top of others
toggle_key = '<C-k>'
}
end
function M.saga()
require('lspsaga').setup {
debug = false,
use_saga_diagnostic_sign = true,
-- diagnostic sign
error_sign = '',
warn_sign = '',
hint_sign = '',
infor_sign = '',
dianostic_header_icon = '',
-- code action title icon
code_action_icon = '',
code_action_prompt = {
enable = false,
sign = true,
sign_priority = 40,
virtual_text = true
},
finder_definition_icon = '',
finder_reference_icon = '',
max_preview_lines = 10,
finder_action_keys = {
open = 'o',
vsplit = 's',
split = 'i',
quit = 'q',
scroll_down = '<C-f>',
scroll_up = '<C-b>'
},
code_action_keys = {
quit = 'q',
exec = '<CR>'
},
rename_action_keys = {
quit = '<C-c>',
exec = '<CR>'
},
definition_preview_icon = '',
border_style = 'single',
rename_prompt_prefix = '',
server_filetype_map = {},
diagnostic_prefix_format = '%d. '
}
end
function M.lsp()
require('modules.lsp.lspconfig')
end
function M.null_ls()
require('modules.lsp.null_ls')
end
function M.sqls()
require('sqls').setup {
picker = 'telescope'
}
end
function M.trouble()
require('trouble').setup {
mode = 'lsp_workspace_diagnostics',
fold_open = '',
fold_closed = '',
action_keys = {
open_split = {'<c-h>'},
open_vsplit = {'<c-v>'},
open_tab = {'<c-t>'}
},
signs = {
error = '',
warning = '',
information = '',
hint = '',
other = ''
}
}
end
function M.todo_comments()
require('todo-comments').setup {
signs = false,
-- sign_priority = 8,
keywords = {
FIX = {
icon = '', -- icon used for the sign, and in search results
color = 'error', -- can be a hex color, or a named color (see below)
alt = {'FIXME', 'BUG', 'FIXIT', 'ISSUE'}, -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually
},
TODO = {icon = '', color = 'info'},
HACK = {icon = '', color = 'warning'},
WARN = {icon = '', color = 'warning', alt = {'WARNING', 'XXX'}},
PERF = {icon = '', alt = {'OPTIM', 'PERFORMANCE', 'OPTIMIZE'}},
NOTE = {icon = '', color = 'hint', alt = {'INFO'}},
},
merge_keywords = true,
highlight = {
before = '', -- 'fg' or 'bg' or empty
keyword = 'fg', -- 'fg', 'bg', 'wide' or empty. (wide is the same as bg, but will also highlight surrounding characters)
after = '', -- 'fg' or 'bg' or empty
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlightng (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {'org'} -- list of file types to exclude highlighting
},
colors = {
error = {'DiagnosticError', 'TSDanger', '#bf616a', '#e06c75'},
warning = {'DiagnosticWarn', 'TSWarning', '#ebcb8b', '#e5c07b'},
info = {'DiagnosticInfo', 'TSNote', '#81a1c1', '#61afef'},
hint = {'DiagnosticHint', '#88c0d0', '#56b6c2'},
default = {'Normal', '#d8dee9', '#abb2bf'}
},
search = {
command = 'rg',
args = {
'--hidden',
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]] -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]] -- match without the extra colon. You'll likely get false positives
}
}
end
function M.symbols_outline()
vim.g.symbols_outline = {
highlight_hovered_item = false,
show_guides = true,
auto_preview = true,
position = 'right',
width = 30,
show_numbers = false,
show_relative_numbers = false,
show_symbol_details = true,
preview_bg_highlight = 'NormalFloat',
keymaps = { -- Can be string or a table
close = {'<Esc>', 'q'},
goto_location = '<Cr>',
focus_location = 'o',
hover_symbol = '<C-space>',
toggle_preview = 'K',
rename_symbol = 'r',
code_actions = 'a',
},
lsp_blacklist = {},
symbol_blacklist = {},
symbols = {
File = {icon = '', hl = 'TSURI'},
Module = {icon = '', hl = 'TSNamespace'},
Namespace = {icon = '', hl = 'TSNamespace'},
Package = {icon = '', hl = 'TSNamespace'},
Class = {icon = '𝓒', hl = 'TSType'},
Method = {icon = 'ƒ', hl = 'TSMethod'},
Property = {icon = '', hl = 'TSMethod'},
Field = {icon = '', hl = 'TSField'},
Constructor = {icon = '', hl = 'TSConstructor'},
Enum = {icon = '', hl = 'TSType'},
Interface = {icon = '', hl = 'TSType'},
Function = {icon = '', hl = 'TSFunction'},
Variable = {icon = '', hl = 'TSConstant'},
Constant = {icon = '', hl = 'TSConstant'},
String = {icon = '𝓐', hl = 'TSString'},
Number = {icon = '#', hl = 'TSNumber'},
Boolean = {icon = '', hl = 'TSBoolean'},
Array = {icon = '', hl = 'TSConstant'},
Object = {icon = '⦿', hl = 'TSType'},
Key = {icon = '🔐', hl = 'TSType'},
Null = {icon = 'NULL', hl = 'TSType'},
EnumMember = {icon = '', hl = 'TSField'},
Struct = {icon = '𝓢', hl = 'TSType'},
Event = {icon = '🗲', hl = 'TSType'},
Operator = {icon = '+', hl = 'TSOperator'},
TypeParameter = {icon = '𝙏', hl = 'TSParameter'}
}
}
end
function M.dap()
local dap = require('dap')
vim.fn.sign_define('DapBreakpoint', {text='', texthl='DapSignDefault'})
vim.fn.sign_define('DapLogPoint', {text='', texthl='DapSignDefault'})
vim.fn.sign_define('DapStopped', {text='', texthl='DapSignDefault'})
vim.fn.sign_define('DapBreakpointRejected', {text='', texthl='DapSignRejected'})
require('mappings').dap()
end
function M.dapui()
local dap, dapui = require('dap'), require('dapui')
dap.listeners.after.event_initialized['dapui_config'] = function() dapui.open() end
dap.listeners.before.event_terminated['dapui_config'] = function() dapui.close() end
dap.listeners.before.event_exited['dapui_config'] = function() dapui.close() end
require('dapui').setup {
icons = {expanded = '', collapsed = ''},
mappings = {
expand = {'<CR>', '<2-LeftMouse>'},
open = 'o',
remove = 'd',
edit = 'e',
repl = 'r'
},
sidebar = {
elements = {
-- Provide as ID strings or tables with 'id' and 'size' keys
-- 'size' can be float or integer > 1
{id = 'scopes', size = 0.25},
{id = 'breakpoints', size = 0.25},
{id = 'stacks', size = 0.25},
{id = 'watches', size = 0.25},
},
size = 40,
position = 'left'
},
tray = {
elements = {'repl'},
size = 10,
position = 'bottom'
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
border = 'single',
mappings = {
close = {'q', '<Esc>'}
}
},
windows = {indent = 1}
}
require('mappings').dapui()
end
return M