summaryrefslogtreecommitdiffstats
path: root/lua/user/lsp
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2022-11-23 15:38:16 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2022-11-23 15:38:16 +0100
commit99630ae8233f8a2afb6a89016b24a354b0186a21 (patch)
tree01ccbb1e8843ce1dbc9383579575dc48eef60f2c /lua/user/lsp
parent904acb28247999214aefd33a0cd3ddcea99d7dc0 (diff)
downloadvim-99630ae8233f8a2afb6a89016b24a354b0186a21.zip
vim-99630ae8233f8a2afb6a89016b24a354b0186a21.tar.gz
plugins -> subdir core
Diffstat (limited to 'lua/user/lsp')
-rw-r--r--lua/user/lsp/handlers.lua94
-rw-r--r--lua/user/lsp/init.lua3
-rw-r--r--lua/user/lsp/mason.lua63
-rw-r--r--lua/user/lsp/null-ls.lua20
-rw-r--r--lua/user/lsp/settings/sumneko_lua.lua16
5 files changed, 0 insertions, 196 deletions
diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua
deleted file mode 100644
index 853beb3..0000000
--- a/lua/user/lsp/handlers.lua
+++ /dev/null
@@ -1,94 +0,0 @@
-local M = {}
-
-local cmp_nvim_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
-if not cmp_nvim_ok then
- print "cpm_nvim_lsp init failed"
- return
-end
-
-M.setup = function()
- local signs = { Error = "", Warn = "", Hint = "", Info = "" }
- for type, icon in pairs(signs) do
- local hl = "DiagnosticSign" .. type
- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
- end
-
- local config = {
- -- disable virtual text
- virtual_text = false,
- -- show signs
- signs = {
- active = signs,
- },
- update_in_insert = false,
- underline = true,
- severity_sort = true,
- float = {
- focusable = false,
- style = "minimal",
- border = "rounded",
- source = "always",
- header = "",
- prefix = "",
- },
- }
-
- vim.diagnostic.config(config)
-
- 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",
- })
-end
-
-local function lsp_highlight(client)
- -- Set autocommands conditional on server_capabilities
- if client.server_capabilities.document_highlight then
- vim.api.nvim_exec(
- [[
- augroup lsp_document_highlight
- autocmd! * <buffer>
- autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
- autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
- augroup END
- ]],
- false
- )
- end
-end
-
-local keymap = vim.keymap.set
-
-local function lsp_keymaps(bufnr)
- local opts = { buffer = bufnr, noremap = true, silent = true }
- -- SEE : https://neovim.io/doc/user/lsp.html
- keymap("n", "gd", vim.lsp.buf.definition, opts)
- keymap("n", "gr", vim.lsp.buf.references, opts)
- keymap("n", "gi", vim.lsp.buf.implementation, opts)
- keymap("n", "ga", vim.lsp.buf.declaration, opts)
-
- keymap("n", "gb", vim.lsp.buf.hover, opts)
- keymap("n", "gé", vim.lsp.buf.signature_help, opts)
- keymap("n", "gk", vim.diagnostic.open_float, opts)
- keymap("n", "g.", vim.diagnostic.goto_next, opts)
- keymap("n", "gx", vim.diagnostic.goto_prev, opts)
- keymap("n", "<leader>q", vim.diagnostic.setloclist, opts)
- vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] -- FIXME what ?
-end
-
-M.on_attach = function(client, bufnr)
- if client.name == "tsserver" then
- client.server_capabilities.document_formatting = false
- end
- lsp_keymaps(bufnr)
- lsp_highlight(client)
-end
-
-local capabilities = vim.lsp.protocol.make_client_capabilities()
-
-M.capabilities = cmp_nvim_lsp.default_capabilities(capabilities)
-
-return M
diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua
deleted file mode 100644
index 50c423a..0000000
--- a/lua/user/lsp/init.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-require 'user.lsp.mason'
-require('user.lsp.handlers').setup()
-require 'user.lsp.null-ls'
diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua
deleted file mode 100644
index b841d72..0000000
--- a/lua/user/lsp/mason.lua
+++ /dev/null
@@ -1,63 +0,0 @@
-local mason_ok, mason = pcall(require, "mason")
-if not mason_ok then
- print "mason init failed"
- return
-end
-
-local mason_lspconfig_ok, mason_lspconfig = pcall(require, "mason-lspconfig")
-if not mason_lspconfig_ok then
- print "mason-lspconfig init failed"
- return
-end
-
-local lspconfig_ok, lspconfig = pcall(require, "lspconfig")
-if not lspconfig_ok then
- print "lspconfig init failed"
- return
-end
-
-require('lspconfig.ui.windows').default_options.border = 'rounded'
-
-local servers = {
- "clangd",
- "jdtls",
- "jsonls",
- "ltex",
- "rust_analyzer",
- "solargraph",
- "sumneko_lua",
-}
-
-mason.setup({
- ui = {
- border = "single",
- icons = {
- package_installed = "✓",
- package_pending = "➜",
- package_uninstalled = "✗"
- }
- }
-})
-
-mason_lspconfig.setup({
- ensure_installed = servers,
-})
-
-mason_lspconfig.setup_handlers({
- function(server_name)
- local opts = {
- on_attach = require("user.lsp.handlers").on_attach,
- capabilities = require("user.lsp.handlers").capabilities,
- falgs = {
- debounce_text_changes = 5000,
- },
- }
-
- local require_ok, server = pcall(require, "user.lsp.settings." .. server_name)
- if require_ok then
- opts = vim.tbl_deep_extend("force", server, opts)
- end
-
- lspconfig[server_name].setup(opts)
- end,
-})
diff --git a/lua/user/lsp/null-ls.lua b/lua/user/lsp/null-ls.lua
deleted file mode 100644
index 389e68f..0000000
--- a/lua/user/lsp/null-ls.lua
+++ /dev/null
@@ -1,20 +0,0 @@
-local null_ls_ok, null_ls = pcall(require, "null-ls")
-if not null_ls_ok then
- print "null-ls init failed"
- return
-end
-
--- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
-local formatting = null_ls.builtins.formatting
--- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
-local diagnostics = null_ls.builtins.diagnostics
-
-null_ls.setup({
- debug = false,
- sources = {
- formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }),
- formatting.black.with({ extra_args = { "--fast" } }),
- formatting.stylua,
- -- diagnostics.flake8
- },
-})
diff --git a/lua/user/lsp/settings/sumneko_lua.lua b/lua/user/lsp/settings/sumneko_lua.lua
deleted file mode 100644
index d7e82b4..0000000
--- a/lua/user/lsp/settings/sumneko_lua.lua
+++ /dev/null
@@ -1,16 +0,0 @@
-return {
- settings = {
-
- Lua = {
- diagnostics = {
- globals = { "vim" }, -- teach about vim global variable
- },
- workspace = {
- library = {
- [vim.fn.expand("$VIMRUNTIME/lua")] = true,
- [vim.fn.stdpath("config") .. "/lua"] = true,
- },
- },
- },
- },
-}