From 97e4abc26bd567535a849fe80ee9b7074c1ec505 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 13 Jun 2024 23:42:57 +0200 Subject: [PATCH] format lspconfig --- lua/plugins/lspconfig.lua | 41 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 6fca8fb..04ad19b 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -3,7 +3,8 @@ local lspKeys = function(client, bufnr) local options = { noremap = true, silent = false, buffer = bufnr } vim.keymap.set('n', ',', vim.diagnostic.goto_prev, vim.tbl_extend('error', options, { desc = 'Diag prev' })) vim.keymap.set('n', ';', vim.diagnostic.goto_next, vim.tbl_extend('error', options, { desc = 'Diag next' })) - vim.keymap.set({ 'n', 'x' }, 'a', vim.lsp.buf.code_action, vim.tbl_extend('error', options, { desc = 'Code action' })) + vim.keymap.set({ 'n', 'x' }, 'a', vim.lsp.buf.code_action, + vim.tbl_extend('error', options, { desc = 'Code action' })) vim.keymap.set('n', 'd', function() fzf.lsp_definitions({ jump_to_single_result = true }) end, vim.tbl_extend('error', options, { desc = 'Definition' })) @@ -11,18 +12,26 @@ local lspKeys = function(client, bufnr) vim.keymap.set('n', 'h', function() require('pretty_hover').hover() end, vim.tbl_extend('error', options, { desc = 'Hover' })) - vim.keymap.set('n', 'c', vim.lsp.buf.outgoing_calls, vim.tbl_extend('error', options, { desc = 'Outgoing calls' })) - vim.keymap.set('n', 'C', vim.lsp.buf.incoming_calls, vim.tbl_extend('error', options, { desc = 'Incoming calls' })) + vim.keymap.set('n', 'c', vim.lsp.buf.outgoing_calls, + vim.tbl_extend('error', options, { desc = 'Outgoing calls' })) + vim.keymap.set('n', 'C', vim.lsp.buf.incoming_calls, + vim.tbl_extend('error', options, { desc = 'Incoming calls' })) vim.keymap.set('n', 'm', vim.lsp.buf.rename, vim.tbl_extend('error', options, { desc = 'Rename' })) - vim.keymap.set('n', '', fzf.lsp_live_workspace_symbols, vim.tbl_extend('error', options, { desc = 'Workspace symbols' })) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, vim.tbl_extend('error', options, { desc = 'Type definition' })) - vim.keymap.set({ 'n', 'i', 'x' }, '', vim.lsp.buf.signature_help, vim.tbl_extend('error', options, { desc = 'Signature help' })) + vim.keymap.set('n', '', fzf.lsp_live_workspace_symbols, + vim.tbl_extend('error', options, { desc = 'Workspace symbols' })) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, + vim.tbl_extend('error', options, { desc = 'Type definition' })) + vim.keymap.set({ 'n', 'i', 'x' }, '', vim.lsp.buf.signature_help, + vim.tbl_extend('error', options, { desc = 'Signature help' })) vim.keymap.set('n', 'r', fzf.lsp_references, vim.tbl_extend('error', options, { desc = 'References' })) vim.keymap.set('n', '', fzf.lsp_document_symbols, vim.tbl_extend('error', options, { desc = 'Document symbols' })) - vim.keymap.set('n', 's', fzf.lsp_live_workspace_symbols, vim.tbl_extend('error', options, { desc = 'Workspace symbols' })) - vim.keymap.set('n', 'v', vim.diagnostic.open_float, vim.tbl_extend('error', options, { desc = 'Diagnostics Float' })) + vim.keymap.set('n', 's', fzf.lsp_live_workspace_symbols, + vim.tbl_extend('error', options, { desc = 'Workspace symbols' })) + vim.keymap.set('n', 'v', vim.diagnostic.open_float, + vim.tbl_extend('error', options, { desc = 'Diagnostics Float' })) vim.keymap.set('n', 'V', fzf.diagnostics_document, vim.tbl_extend('error', options, { desc = 'Diagnostics' })) - vim.keymap.set('n', '', 'ClangdSwitchSourceHeader', vim.tbl_extend('error', options, { desc = 'Switch Source/Header' })) + vim.keymap.set('n', '', 'ClangdSwitchSourceHeader', + vim.tbl_extend('error', options, { desc = 'Switch Source/Header' })) -- Set some keybinds conditional on server capabilities if client.server_capabilities.documentFormattingProvider then @@ -146,9 +155,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 @@ -199,7 +208,7 @@ 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({}) @@ -221,7 +230,8 @@ return { '--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'), + root_dir = lspconfig.util.root_pattern('.clangd', '.clang-tidy', '.clang-format', 'compile_flags.txt', + 'configure.ac', '.git', 'build_nvim'), }) require('clangd_extensions').setup({ @@ -332,7 +342,8 @@ 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, }, })