2022-12-22 20:41:30 +00:00
|
|
|
|
local lspconfig = require "lspconfig"
|
2022-06-12 19:25:17 +00:00
|
|
|
|
|
2023-06-02 17:03:31 +00:00
|
|
|
|
local workspace_library = vim.api.nvim_get_runtime_file("lua", true)
|
|
|
|
|
|
table.insert(workspace_library, os.getenv("HOME") .. "/Code/src/github.com/AdeAttwood/Configz/definitions/configz.lua")
|
|
|
|
|
|
|
2022-12-22 20:38:56 +00:00
|
|
|
|
local servers = {
|
2022-12-22 20:41:30 +00:00
|
|
|
|
-- Language servers for the day to day web development, could probably think
|
2023-01-20 07:55:11 +00:00
|
|
|
|
-- about loosing the html and css one and living with typescript, rescript
|
|
|
|
|
|
-- and emmet
|
2022-12-22 20:41:30 +00:00
|
|
|
|
tsserver = {},
|
2023-01-20 07:55:11 +00:00
|
|
|
|
rescriptls = {
|
|
|
|
|
|
cmd = {
|
|
|
|
|
|
os.getenv "NVM_BIN" .. "/node",
|
|
|
|
|
|
os.getenv "HOME" .. "/.config/nvim/pack/bundle/start/vim-rescript/server/out/server.js",
|
|
|
|
|
|
"--stdio",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2022-12-22 20:41:30 +00:00
|
|
|
|
html = {},
|
|
|
|
|
|
cssls = {},
|
2023-04-25 20:00:23 +00:00
|
|
|
|
clojure_lsp = {},
|
2022-12-22 20:41:30 +00:00
|
|
|
|
emmet_ls = {
|
|
|
|
|
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "scss", "eruby" },
|
|
|
|
|
|
},
|
|
|
|
|
|
-- Ruby
|
|
|
|
|
|
solargraph = {},
|
|
|
|
|
|
-- Rust
|
|
|
|
|
|
rust_analyzer = {},
|
|
|
|
|
|
-- Lua for the vim config and plugin dev
|
2023-04-25 19:37:52 +00:00
|
|
|
|
lua_ls = {
|
2022-12-22 20:41:30 +00:00
|
|
|
|
settings = {
|
|
|
|
|
|
Lua = {
|
|
|
|
|
|
telemetry = { enable = false },
|
2023-06-02 17:03:31 +00:00
|
|
|
|
runtime = { version = "LuaJIT" },
|
|
|
|
|
|
diagnostics = { globals = { "vim", "configz" } },
|
|
|
|
|
|
workspace = {
|
|
|
|
|
|
library = workspace_library,
|
|
|
|
|
|
checkThirdParty = false,
|
|
|
|
|
|
},
|
2022-12-22 20:41:30 +00:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2022-12-22 20:38:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local on_attach = function(_, bufnr)
|
2022-12-22 20:41:30 +00:00
|
|
|
|
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
2022-06-12 19:25:17 +00:00
|
|
|
|
|
2022-12-22 20:41:30 +00:00
|
|
|
|
local opts = { noremap = true, silent = true }
|
2022-06-12 19:25:17 +00:00
|
|
|
|
|
2022-12-22 20:41:30 +00:00
|
|
|
|
-- Mappings.
|
|
|
|
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
2022-06-12 19:25:17 +00:00
|
|
|
|
|
2022-12-22 20:41:30 +00:00
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
2023-05-16 18:27:45 +00:00
|
|
|
|
|
|
|
|
|
|
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
|
|
|
|
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
|
|
|
|
|
buffer = bufnr,
|
|
|
|
|
|
callback = function ()
|
|
|
|
|
|
-- Highlight document symbles for every file type other erb files because
|
|
|
|
|
|
-- solargraph only supports textDocument/documentHighlight in rb files.
|
|
|
|
|
|
local file_type = vim.api.nvim_buf_get_option(0, "filetype")
|
|
|
|
|
|
if file_type ~= "eruby" then
|
|
|
|
|
|
vim.lsp.buf.document_highlight()
|
|
|
|
|
|
end
|
|
|
|
|
|
end,
|
|
|
|
|
|
group = "lsp_document_highlight",
|
|
|
|
|
|
desc = "Document Highlight",
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
|
|
|
|
|
buffer = bufnr,
|
|
|
|
|
|
callback = function ()
|
|
|
|
|
|
vim.lsp.buf.clear_references()
|
|
|
|
|
|
end,
|
|
|
|
|
|
group = "lsp_document_highlight",
|
|
|
|
|
|
desc = "Clear All the References",
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2022-06-12 19:25:17 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
2023-02-09 19:44:18 +00:00
|
|
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
2022-06-12 19:25:17 +00:00
|
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
|
|
|
2022-12-22 20:38:56 +00:00
|
|
|
|
for lsp, config in pairs(servers) do
|
2022-12-22 20:41:30 +00:00
|
|
|
|
config["on_attach"] = on_attach
|
|
|
|
|
|
config["capabilities"] = capabilities
|
|
|
|
|
|
config["init_options"] = { usePlaceholders = true }
|
2022-06-12 19:25:17 +00:00
|
|
|
|
|
2022-12-22 20:41:30 +00:00
|
|
|
|
lspconfig[lsp].setup(config)
|
2022-12-22 20:38:56 +00:00
|
|
|
|
end
|
2022-07-10 20:14:19 +00:00
|
|
|
|
|
2022-06-12 19:25:17 +00:00
|
|
|
|
-- Change the diagnostic signs
|
2022-12-22 20:12:50 +00:00
|
|
|
|
vim.fn.sign_define("DiagnosticSignHint", { text = "➤", texthl = "DiagnosticSignHint", numhl = "DiagnosticSignHint" })
|
|
|
|
|
|
vim.fn.sign_define("DiagnosticSignInfo", { text = "ℹ", texthl = "DiagnosticSignInfo", numhl = "DiagnosticSignInfo" })
|
|
|
|
|
|
vim.fn.sign_define("DiagnosticSignWarn", { text = "⚠", texthl = "DiagnosticSignWarn", numhl = "DiagnosticSignWarn" })
|
|
|
|
|
|
vim.fn.sign_define(
|
2022-12-22 20:41:30 +00:00
|
|
|
|
"DiagnosticSignError",
|
|
|
|
|
|
{ text = "✖", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" }
|
2022-12-22 20:12:50 +00:00
|
|
|
|
)
|
2023-01-20 07:55:47 +00:00
|
|
|
|
|
|
|
|
|
|
local border = 'rounded'
|
|
|
|
|
|
|
|
|
|
|
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border})
|
|
|
|
|
|
vim.lsp.handlers["textDocument/show_line_diagnostics"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border})
|
|
|
|
|
|
vim.lsp.handlers["textDocument/diagnostic"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border})
|
|
|
|
|
|
vim.lsp.handlers["textDocument/diagnostics"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border})
|
|
|
|
|
|
vim.diagnostic.config({
|
|
|
|
|
|
float = {
|
|
|
|
|
|
focusable=false,
|
|
|
|
|
|
border = border
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-03-16 20:48:12 +00:00
|
|
|
|
|
|
|
|
|
|
vim.cmd([[set updatetime=1000]])
|
2023-05-16 18:27:45 +00:00
|
|
|
|
vim.api.nvim_create_augroup("diagnostic_float", { clear = true })
|
2023-03-16 20:48:12 +00:00
|
|
|
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
|
|
|
|
|
callback = function ()
|
|
|
|
|
|
vim.diagnostic.open_float()
|
|
|
|
|
|
end,
|
2023-05-16 18:27:45 +00:00
|
|
|
|
group = "diagnostic_float",
|
|
|
|
|
|
desc = "Open Diagnostic Float",
|
2023-03-16 20:48:12 +00:00
|
|
|
|
})
|