moved mason to its own file

This commit is contained in:
Oliver Hartmann 2024-06-14 23:52:06 +02:00
parent 51812867b2
commit 48e0a8f399
2 changed files with 68 additions and 34 deletions

View File

@ -3,7 +3,8 @@ local lspKeys = function(client, bufnr)
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', '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' }))
@ -11,18 +12,26 @@ local lspKeys = function(client, bufnr)
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>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', '<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>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', '<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
@ -94,32 +103,13 @@ return {
'neovim/nvim-lspconfig',
dependencies = {
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
'p00f/clangd_extensions.nvim',
'Fildo7525/pretty_hover',
'creativenull/efmls-configs-nvim',
},
build = ':MasonUpdate',
version = nil,
branch = 'master',
config = function()
require('mason').setup({
ui = {
border = 'rounded',
},
})
require('mason-lspconfig').setup({
automatic_installation = false,
ensure_installed = {
'clangd',
'basedpyright',
-- 'neocmake',
'efm',
'lua_ls',
'jsonls',
'markdown_oxide',
},
})
local lspconfig = require('lspconfig')
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
@ -138,9 +128,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
@ -191,7 +181,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({})
@ -213,7 +203,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({
@ -324,7 +315,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,
},
})

42
lua/plugins/mason.lua Normal file
View File

@ -0,0 +1,42 @@
return {
'williamboman/mason.nvim',
dependencies = {
'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
},
build = ':MasonUpdate',
branch = 'master',
config = function()
require('mason').setup({
ui = {
border = 'rounded',
},
})
require('mason-lspconfig').setup({
automatic_installation = false,
ensure_installed = {
'clangd',
'basedpyright',
-- 'neocmake',
'efm',
'lua_ls',
'jsonls',
'markdown_oxide',
},
})
require('mason-tool-installer').setup({
-- a list of all tools you want to ensure are installed upon
-- start
ensure_installed = {
'black',
'flake8',
'isort',
'prettier',
'stylua',
'gersemi',
'cmakelang',
},
})
end,
}