local function config() local signs = { { name = 'DiagnosticSignError', text = '' }, { name = 'DiagnosticSignWarn', text = '' }, { name = 'DiagnosticSignHint', text = '' }, { name = 'DiagnosticSignInfo', text = '' }, } for _, sign in ipairs(signs) do vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = '' }) end vim.diagnostic.config({ virtual_text = false, signs = { active = signs, }, update_in_insert = true, underline = true, severity_sort = true, float = { focusable = false, style = 'minimal', border = 'rounded', source = 'always', header = '', prefix = '', }, }) vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded', }) vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded', }) vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = false, }) local lspconfig = require('lspconfig') local function lsp_keymaps(bufnr) local opts = { noremap = true, silent = true } vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'go', 'lua vim.diagnostic.open_float()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', 'lua vim.diagnostic.goto_prev({ border = "rounded" })', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', 'lua vim.diagnostic.goto_next({ border = "rounded" })', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'lf', 'lua vim.lsp.buf.format()', opts) --vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] end local on_attach = function(client, bufnr) lsp_keymaps(bufnr) end -- lua-language-server -- pacman -S lua-language-server lspconfig.lua_ls.setup({ on_attach = on_attach, settings = { Lua = { format = { enable = false, }, diagnostics = { globals = { 'vim' }, }, workspace = { library = { -- include neovim runtime files [vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, }, checkThirdParty = false, -- disable "do you want to set up the workspace" }, telemetry = { enable = false, }, }, }, }) -- vim.g.python3_host_prog = '/home/peters/src/invsys/docker-path/python' -- pyright -- pip install pyright lspconfig.pyright.setup({ -- cmd = { '/home/peters/src/invsys/docker-path/pyright-langserver', '--stdio' }, -- cmd = { 'pyright-langserver', '--stdio' }, on_attach = on_attach, root_dir = require('lspconfig.util').root_pattern('pyproject.toml'), settings = { python = { analysis = { autoSearchPaths = true, useLibraryCodeForTypes = false, diagnosticMode = 'openFilesOnly', }, }, }, }) -- pip install ruff ruff-lsp lspconfig.ruff_lsp.setup({ on_attach = on_attach, init_options = { settings = { args = { -- disable distracting whitespace rules '--ignore', 'W291,W293', }, }, }, }) -- vscode-json-language-server -- npm i -g vscode-langservers-extracted lspconfig.jsonls.setup({ on_attach = on_attach, }) -- typescript-language-server -- npm i -g typescript-language-server lspconfig.tsserver.setup({ on_attach = on_attach, }) -- rustup lspconfig.rust_analyzer.setup({ on_attach = on_attach, }) end return config