format with stylua
This commit is contained in:
@@ -1,66 +1,49 @@
|
||||
local lspKeys = function(client, bufnr)
|
||||
local fzf = require('fzf-lua')
|
||||
local options = { noremap = true, silent = false, buffer = bufnr }
|
||||
vim.keymap.set('n', '<space>,', vim.diagnostic.goto_prev,
|
||||
vim.tbl_extend('error', options, { desc = 'Diag prev' }))
|
||||
vim.keymap.set('n', '<space>;', vim.diagnostic.goto_next,
|
||||
vim.tbl_extend('error', options, { desc = 'Diag next' }))
|
||||
vim.keymap.set({ 'n', 'x' }, '<space>a', vim.lsp.buf.code_action,
|
||||
vim.tbl_extend('error', options, { desc = 'Code action' }))
|
||||
vim.keymap.set('n', '<space>d', function() fzf.lsp_definitions({ jump_to_single_result = true }) end,
|
||||
vim.tbl_extend('error', options, { desc = 'Definition' }))
|
||||
vim.keymap.set('n', '<space>e',
|
||||
vim.lsp.buf.declaration, vim.tbl_extend('error', options, { desc = 'Declaration' }))
|
||||
vim.keymap.set('n', '<space>h', function() require('pretty_hover').hover() end,
|
||||
vim.tbl_extend('error', options, { desc = 'Hover' }))
|
||||
vim.keymap.set('n', '<space>c', vim.lsp.buf.outgoing_calls,
|
||||
vim.tbl_extend('error', options, { desc = 'Outgoing calls' }))
|
||||
vim.keymap.set('n', '<space>C', vim.lsp.buf.incoming_calls,
|
||||
vim.tbl_extend('error', options, { desc = 'Incoming calls' }))
|
||||
vim.keymap.set('n', '<space>m', vim.lsp.buf.rename,
|
||||
vim.tbl_extend('error', options, { desc = 'Rename' }))
|
||||
vim.keymap.set('n', '<C-t>', fzf.lsp_live_workspace_symbols,
|
||||
vim.tbl_extend('error', options, { desc = 'Workspace symbols' }))
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition,
|
||||
vim.tbl_extend('error', options, { desc = 'Type definition' }))
|
||||
vim.keymap.set({ 'n', 'i', 'x' }, '<C-k>', vim.lsp.buf.signature_help,
|
||||
vim.tbl_extend('error', options, { desc = 'Signature help' }))
|
||||
vim.keymap.set('n', '<space>r', fzf.lsp_references,
|
||||
vim.tbl_extend('error', options, { desc = 'References' }))
|
||||
vim.keymap.set('n', '<A-m>', fzf.lsp_document_symbols,
|
||||
vim.tbl_extend('error', options, { desc = 'Document symbols' }))
|
||||
vim.keymap.set('n', '<space>s', fzf.lsp_live_workspace_symbols,
|
||||
vim.tbl_extend('error', options, { desc = 'Workspace symbols' }))
|
||||
vim.keymap.set('n', '<space>v', vim.diagnostic.open_float,
|
||||
vim.tbl_extend('error', options, { desc = 'Diagnostics Float' }))
|
||||
vim.keymap.set('n', '<space>V', fzf.diagnostics_document,
|
||||
vim.tbl_extend('error', options, { desc = 'Diagnostics' }))
|
||||
vim.keymap.set('n', '<A-o>', '<cmd>ClangdSwitchSourceHeader<CR>',
|
||||
vim.tbl_extend('error', options, { desc = 'Switch Source/Header' }))
|
||||
vim.keymap.set('n', '<space>,', vim.diagnostic.goto_prev, vim.tbl_extend('error', options, { desc = 'Diag prev' }))
|
||||
vim.keymap.set('n', '<space>;', vim.diagnostic.goto_next, vim.tbl_extend('error', options, { desc = 'Diag next' }))
|
||||
vim.keymap.set({ 'n', 'x' }, '<space>a', vim.lsp.buf.code_action, vim.tbl_extend('error', options, { desc = 'Code action' }))
|
||||
vim.keymap.set('n', '<space>d', function()
|
||||
fzf.lsp_definitions({ jump_to_single_result = true })
|
||||
end, vim.tbl_extend('error', options, { desc = 'Definition' }))
|
||||
vim.keymap.set('n', '<space>e', vim.lsp.buf.declaration, vim.tbl_extend('error', options, { desc = 'Declaration' }))
|
||||
vim.keymap.set('n', '<space>h', function()
|
||||
require('pretty_hover').hover()
|
||||
end, vim.tbl_extend('error', options, { desc = 'Hover' }))
|
||||
vim.keymap.set('n', '<space>c', vim.lsp.buf.outgoing_calls, vim.tbl_extend('error', options, { desc = 'Outgoing calls' }))
|
||||
vim.keymap.set('n', '<space>C', vim.lsp.buf.incoming_calls, vim.tbl_extend('error', options, { desc = 'Incoming calls' }))
|
||||
vim.keymap.set('n', '<space>m', vim.lsp.buf.rename, vim.tbl_extend('error', options, { desc = 'Rename' }))
|
||||
vim.keymap.set('n', '<C-t>', fzf.lsp_live_workspace_symbols, vim.tbl_extend('error', options, { desc = 'Workspace symbols' }))
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, vim.tbl_extend('error', options, { desc = 'Type definition' }))
|
||||
vim.keymap.set({ 'n', 'i', 'x' }, '<C-k>', vim.lsp.buf.signature_help, vim.tbl_extend('error', options, { desc = 'Signature help' }))
|
||||
vim.keymap.set('n', '<space>r', fzf.lsp_references, vim.tbl_extend('error', options, { desc = 'References' }))
|
||||
vim.keymap.set('n', '<A-m>', fzf.lsp_document_symbols, vim.tbl_extend('error', options, { desc = 'Document symbols' }))
|
||||
vim.keymap.set('n', '<space>s', fzf.lsp_live_workspace_symbols, vim.tbl_extend('error', options, { desc = 'Workspace symbols' }))
|
||||
vim.keymap.set('n', '<space>v', vim.diagnostic.open_float, vim.tbl_extend('error', options, { desc = 'Diagnostics Float' }))
|
||||
vim.keymap.set('n', '<space>V', fzf.diagnostics_document, vim.tbl_extend('error', options, { desc = 'Diagnostics' }))
|
||||
vim.keymap.set('n', '<A-o>', '<cmd>ClangdSwitchSourceHeader<CR>', vim.tbl_extend('error', options, { desc = 'Switch Source/Header' }))
|
||||
|
||||
-- Set some keybinds conditional on server capabilities
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.keymap.set('n', '<space>f', function()
|
||||
vim.lsp.buf.format({ timeout_ms = 10000 })
|
||||
end,
|
||||
{ noremap = true, silent = false, desc = 'Format file', buffer = bufnr })
|
||||
vim.lsp.buf.format({ timeout_ms = 10000 })
|
||||
end, { noremap = true, silent = false, desc = 'Format file', buffer = bufnr })
|
||||
end
|
||||
if client.server_capabilities.documentRangeFormattingProvider then
|
||||
vim.keymap.set('x', '<space>f', function()
|
||||
vim.lsp.buf.format({ timeout_ms = 10000 })
|
||||
end,
|
||||
{ noremap = true, silent = false, desc = 'Format visual', buffer = bufnr })
|
||||
vim.lsp.buf.format({ timeout_ms = 10000 })
|
||||
end, { noremap = true, silent = false, desc = 'Format visual', buffer = bufnr })
|
||||
end
|
||||
if client.supports_method('inlayHintProvider') then
|
||||
vim.keymap.set('n', '<space>i', function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr })
|
||||
end,
|
||||
{
|
||||
noremap = true,
|
||||
silent = false,
|
||||
desc = 'Toggle inlay hints',
|
||||
buffer = bufnr
|
||||
})
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr })
|
||||
end, {
|
||||
noremap = true,
|
||||
silent = false,
|
||||
desc = 'Toggle inlay hints',
|
||||
buffer = bufnr,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -88,10 +71,10 @@ local document_highlight = function(bufnr)
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds {
|
||||
vim.api.nvim_clear_autocmds({
|
||||
group = group,
|
||||
buffer = bufnr
|
||||
}
|
||||
buffer = bufnr,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
@@ -127,8 +110,8 @@ return {
|
||||
config = function()
|
||||
require('mason').setup({
|
||||
ui = {
|
||||
border = 'rounded'
|
||||
}
|
||||
border = 'rounded',
|
||||
},
|
||||
})
|
||||
require('mason-lspconfig').setup({
|
||||
automatic_installation = false,
|
||||
@@ -141,7 +124,7 @@ return {
|
||||
'lua_ls',
|
||||
'jsonls',
|
||||
-- 'groovyls', -- Doesn't work in WSL
|
||||
}
|
||||
},
|
||||
})
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
@@ -161,9 +144,9 @@ return {
|
||||
}
|
||||
local signs = {
|
||||
{ name = 'DiagnosticSignError', text = diagnostics.Error },
|
||||
{ name = 'DiagnosticSignWarn', text = diagnostics.Warning },
|
||||
{ name = 'DiagnosticSignHint', text = diagnostics.Hint },
|
||||
{ name = 'DiagnosticSignInfo', text = diagnostics.Information },
|
||||
{ name = 'DiagnosticSignWarn', text = diagnostics.Warning },
|
||||
{ name = 'DiagnosticSignHint', text = diagnostics.Hint },
|
||||
{ name = 'DiagnosticSignInfo', text = diagnostics.Information },
|
||||
}
|
||||
|
||||
for _, sign in ipairs(signs) do
|
||||
@@ -179,13 +162,12 @@ return {
|
||||
vim.diagnostic.open_float({ focusable = false, width = 80 })
|
||||
end
|
||||
|
||||
|
||||
-- lspconfig['pyright'].setup {
|
||||
-- capabilities = capabilities,
|
||||
-- on_attach = on_attach,
|
||||
-- }
|
||||
|
||||
lspconfig['basedpyright'].setup {
|
||||
lspconfig['basedpyright'].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
@@ -193,12 +175,12 @@ return {
|
||||
typeCheckingMode = 'standard',
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
lspconfig['groovyls'].setup {
|
||||
lspconfig['groovyls'].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
})
|
||||
|
||||
-- lspconfig['cmake'].setup {
|
||||
-- capabilities = capabilities,
|
||||
@@ -215,8 +197,8 @@ return {
|
||||
return lspconfig.util.find_git_ancestor(fname)
|
||||
end,
|
||||
single_file_support = true, -- suggested
|
||||
on_attach = on_attach -- on_attach is the on_attach function you defined
|
||||
}
|
||||
on_attach = on_attach, -- on_attach is the on_attach function you defined
|
||||
},
|
||||
}
|
||||
lspconfig.neocmake.setup({})
|
||||
end
|
||||
@@ -224,48 +206,42 @@ return {
|
||||
local clangd_capabilities = capabilities
|
||||
clangd_capabilities.textDocument.semanticHighlighting = true
|
||||
clangd_capabilities.offsetEncoding = { 'utf-16' }
|
||||
lspconfig['clangd'].setup {
|
||||
lspconfig['clangd'].setup({
|
||||
capabilities = clangd_capabilities,
|
||||
on_attach = on_attach,
|
||||
cmd = { 'clangd',
|
||||
cmd = {
|
||||
'clangd',
|
||||
'--compile-commands-dir=build_nvim',
|
||||
'--query-driver', '/opt/cortex-a78-2022.08-gcc12.1-linux5.15/bin/aarch64-linux-gnu-g*',
|
||||
'--query-driver',
|
||||
'/opt/cortex-a78-2022.08-gcc12.1-linux5.15/bin/aarch64-linux-gnu-g*',
|
||||
'--clang-tidy',
|
||||
'--background-index',
|
||||
'--use-dirty-headers',
|
||||
'--completion-style=detailed' },
|
||||
root_dir = lspconfig.util.root_pattern(
|
||||
'.clangd',
|
||||
'.clang-tidy',
|
||||
'.clang-format',
|
||||
'compile_flags.txt',
|
||||
'configure.ac',
|
||||
'.git',
|
||||
'build_nvim'
|
||||
)
|
||||
}
|
||||
'--completion-style=detailed',
|
||||
},
|
||||
root_dir = lspconfig.util.root_pattern('.clangd', '.clang-tidy', '.clang-format', 'compile_flags.txt', 'configure.ac', '.git', 'build_nvim'),
|
||||
})
|
||||
|
||||
require('clangd_extensions').setup({
|
||||
extensions =
|
||||
{
|
||||
extensions = {
|
||||
inlay_hints = {
|
||||
-- Only show inlay hints for the current line
|
||||
only_current_line = true,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
lspconfig['jsonls'].setup {
|
||||
lspconfig['jsonls'].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
})
|
||||
|
||||
-- lspconfig['rust_analyzer'].setup {
|
||||
-- capabilities = capabilities,
|
||||
-- on_attach = on_attach,
|
||||
-- }
|
||||
|
||||
lspconfig['lua_ls'].setup {
|
||||
lspconfig['lua_ls'].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
@@ -274,7 +250,7 @@ return {
|
||||
checkThirdParty = false,
|
||||
},
|
||||
completion = {
|
||||
callSnippet = 'Replace'
|
||||
callSnippet = 'Replace',
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
@@ -286,36 +262,36 @@ return {
|
||||
indent_style = 'space',
|
||||
indent_size = '2',
|
||||
quote_style = 'single',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
lspconfig['dockerls'].setup {
|
||||
lspconfig['dockerls'].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
})
|
||||
|
||||
lspconfig['markdown_oxide'].setup {
|
||||
lspconfig['markdown_oxide'].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
})
|
||||
|
||||
-- lspconfig['marksman'].setup {
|
||||
-- capabilities = capabilities,
|
||||
-- on_attach = on_attach,
|
||||
-- }
|
||||
|
||||
lspconfig['yamlls'].setup {
|
||||
lspconfig['yamlls'].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
yaml = {
|
||||
validate = true
|
||||
}
|
||||
}
|
||||
}
|
||||
validate = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
local prettier = require('efmls-configs.formatters.prettier')
|
||||
local stylua = require('efmls-configs.formatters.stylua')
|
||||
@@ -352,15 +328,10 @@ return {
|
||||
float = {
|
||||
border = 'single',
|
||||
format = function(diagnostic)
|
||||
return string.format(
|
||||
'%s (%s) [%s]',
|
||||
diagnostic.message,
|
||||
diagnostic.source,
|
||||
diagnostic.code or diagnostic.user_data.lsp.code
|
||||
)
|
||||
return string.format('%s (%s) [%s]', diagnostic.message, diagnostic.source, diagnostic.code or diagnostic.user_data.lsp.code)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
event = 'VeryLazy'
|
||||
event = 'VeryLazy',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user