Lsp changes (deprecations etc)
parent
2754087154
commit
df5749ecd3
|
@ -1,209 +1,166 @@
|
||||||
-- import lspconfig plugin safely
|
-- import lspconfig plugin safely
|
||||||
local lspconfig_status, lspconfig = pcall(require, "lspconfig")
|
local lspconfig_status, lspconfig = pcall(require, "lspconfig")
|
||||||
if not lspconfig_status then
|
if not lspconfig_status then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- import cmp-nvim-lsp plugin safely
|
-- import cmp-nvim-lsp plugin safely
|
||||||
local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
if not cmp_nvim_lsp_status then
|
if not cmp_nvim_lsp_status then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local keymap = vim.keymap -- for conciseness
|
local keymap = vim.keymap -- for conciseness
|
||||||
|
|
||||||
---------- border >------------------------------
|
---------- border >------------------------------
|
||||||
local _border = "single"
|
local orig_floating_preview = vim.lsp.util.open_floating_preview
|
||||||
require('lspconfig.ui.windows').default_options = {
|
vim.lsp.util.open_floating_preview = function(contents, syntax, opts, ...)
|
||||||
border = _border
|
opts = opts or {}
|
||||||
}
|
opts.border = "rounded" -- You can also use "single", "double", or "shadow"
|
||||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
|
return orig_floating_preview(contents, syntax, opts, ...)
|
||||||
vim.lsp.handlers.hover, {
|
end
|
||||||
border = _border
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
|
||||||
vim.lsp.handlers.signature_help, {
|
|
||||||
border = _border
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
vim.diagnostic.config {
|
|
||||||
float = { border = _border }
|
|
||||||
}
|
|
||||||
---------- </border ------------------------------
|
---------- </border ------------------------------
|
||||||
|
vim.diagnostic.config({ virtual_lines = { current_line = true } })
|
||||||
|
|
||||||
-- enable keybinds only for when lsp server available
|
-- enable keybinds only for when lsp server available
|
||||||
local on_attach = function(_, bufnr)
|
local on_attach = function(_, bufnr)
|
||||||
-- keybind options
|
-- keybind options
|
||||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||||
|
|
||||||
keymap.set("n", "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", opts)
|
keymap.set("n", "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", opts)
|
||||||
-- keymap.set("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
-- keymap.set("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) keymap.set("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) -- got to declaration
|
||||||
keymap.set("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) -- got to declaration
|
keymap.set("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) -- see definition and make edits in window
|
||||||
keymap.set("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) -- see definition and make edits in window
|
keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) -- go to implementation
|
||||||
keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) -- go to implementation
|
keymap.set("n", "<leader>l", "<cmd>lua vim.lsp.buf.format()<CR>", opts) -- format code
|
||||||
keymap.set("n", "<leader>l", "<cmd>lua vim.lsp.buf.format()<CR>", opts) -- format code
|
keymap.set("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) -- format code
|
||||||
keymap.set("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) -- format code
|
-- keymap.set("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) -- see available code actions
|
||||||
-- keymap.set("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) -- see available code actions
|
-- keymap.set("n", "<leader>ed", "<cmd>Telescope diagnostics<CR>", opts) -- jump to previous diagnostic in buffer
|
||||||
-- keymap.set("n", "<leader>ed", "<cmd>Telescope diagnostics<CR>", opts) -- jump to previous diagnostic in buffer
|
-- keymap.set("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) -- show documentation for what is under cursor
|
||||||
-- keymap.set("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) -- show documentation for what is under cursor
|
keymap.set(
|
||||||
keymap.set(
|
"n",
|
||||||
"n",
|
"<leader>cbf",
|
||||||
"<leader>cbf",
|
":!phpcbf -w --standard=PSR12 %<CR>",
|
||||||
":!phpcbf -w --standard=PSR12 %<CR>",
|
{ noremap = true, silent = false, buffer = bufnr }
|
||||||
{ noremap = true, silent = false, buffer = bufnr }
|
)
|
||||||
)
|
|
||||||
|
|
||||||
keymap.set("n", "<leader>o", "<cmd>Lspsaga outline<CR>", opts) -- see outline on right hand side
|
keymap.set("n", "<leader>o", "<cmd>Lspsaga outline<CR>", opts) -- see outline on right hand side
|
||||||
keymap.set("n", "<leader>ss", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts) -- workspace symbols
|
keymap.set("n", "<leader>ss", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts) -- workspace symbols
|
||||||
|
|
||||||
|
|
||||||
-- LSP Saga
|
-- LSP Saga
|
||||||
keymap.set("n", "gsd", "<cmd>Lspsaga peek_definition<CR>", opts) -- see definition and make edits in window
|
keymap.set("n", "gsd", "<cmd>Lspsaga peek_definition<CR>", opts) -- see definition and make edits in window
|
||||||
keymap.set("n", "gr", "<cmd>Lspsaga finder<CR>", opts) -- see definition and make edits in window
|
keymap.set("n", "gr", "<cmd>Lspsaga finder<CR>", opts) -- see definition and make edits in window
|
||||||
keymap.set("n", "<leader>rn", "<cmd>Lspsaga rename<CR>", opts) -- smart rename
|
keymap.set("n", "<leader>rn", "<cmd>Lspsaga rename<CR>", opts) -- smart rename
|
||||||
keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", opts) -- see available code actions
|
keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", opts) -- see available code actions
|
||||||
keymap.set("n", "K", "<cmd>Lspsaga hover_doc<CR>", opts) -- show documentation for what is under cursor
|
keymap.set("n", "K", "<cmd>Lspsaga hover_doc<CR>", opts) -- show documentation for what is under cursor
|
||||||
keymap.set("n", "ge", "<cmd>Lspsaga show_line_diagnostics<CR>", opts) -- show diagnostics for line
|
keymap.set("n", "ge", "<cmd>Lspsaga show_line_diagnostics<CR>", opts) -- show diagnostics for line
|
||||||
keymap.set("n", "<a-cr>", "<cmd>Lspsaga code_action<CR>", opts)
|
keymap.set("n", "<a-cr>", "<cmd>Lspsaga code_action<CR>", opts)
|
||||||
-- diagnostic
|
-- diagnostic
|
||||||
keymap.set("n", "<leader>d", "<cmd>Telescope diagnostics<CR>", opts) -- jump to previous diagnostic in buffer
|
keymap.set("n", "<leader>d", "<cmd>Telescope diagnostics<CR>", opts) -- jump to previous diagnostic in buffer
|
||||||
-- keymap.set("n", "<leader>d", "<cmd>Lspsaga show_buf_diagnostics<CR>")
|
-- keymap.set("n", "<leader>d", "<cmd>Lspsaga show_buf_diagnostics<CR>")
|
||||||
keymap.set("n", "<leader>dn", "<cmd>Lspsaga diagnostic_jump_next<CR>") -- jump to next diagnostic in buffer
|
keymap.set("n", "<leader>dn", "<cmd>Lspsaga diagnostic_jump_next<CR>") -- jump to next diagnostic in buffer
|
||||||
keymap.set("n", "<leader>dp", "<cmd>Lspsaga diagnostic_jump_prev<CR>") -- jump to previous diagnostic in buffer
|
keymap.set("n", "<leader>dp", "<cmd>Lspsaga diagnostic_jump_prev<CR>") -- jump to previous diagnostic in buffer
|
||||||
|
|
||||||
keymap.set("n", "gj", "<cmd>lua require'nvim-treesitter.textobjects.move'.goto_next_start('@function.outer')<CR>",
|
keymap.set("n", "gj", "<cmd>lua require'nvim-treesitter.textobjects.move'.goto_next_start('@function.outer')<CR>",
|
||||||
opts) -- jump to next method
|
opts) -- jump to next method
|
||||||
keymap.set("n", "gk", "<cmd>lua require'nvim-treesitter.textobjects.move'.goto_previous_start('@function.outer')<CR>",
|
keymap.set("n", "gk", "<cmd>lua require'nvim-treesitter.textobjects.move'.goto_previous_start('@function.outer')<CR>",
|
||||||
opts) -- jump to previous method
|
opts) -- jump to previous method
|
||||||
end
|
end
|
||||||
|
|
||||||
-- used to enable autocompletion (assign to every lsp server config)
|
-- used to enable autocompletion (assign to every lsp server config)
|
||||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||||
|
|
||||||
-- Change the Diagnostic symbols in the sign column (gutter)
|
|
||||||
-- (not in youtube nvim video)
|
|
||||||
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 = "" })
|
|
||||||
end
|
|
||||||
|
|
||||||
local lsp_flags = {
|
|
||||||
-- This is the default in Nvim 0.7+
|
|
||||||
debounce_text_changes = 150,
|
|
||||||
}
|
|
||||||
|
|
||||||
lspconfig["bashls"].setup({
|
lspconfig["bashls"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "sh", "bin" },
|
filetypes = { "sh", "bin" },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- XML LSP
|
-- XML LSP
|
||||||
lspconfig["lemminx"].setup({
|
lspconfig["lemminx"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "xml" },
|
filetypes = { "xml" },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- yaml LSP
|
-- yaml LSP
|
||||||
lspconfig["yamlls"].setup({
|
lspconfig["yamlls"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "yaml", "yml" },
|
filetypes = { "yaml", "yml" },
|
||||||
})
|
})
|
||||||
-- json LSP
|
-- json LSP
|
||||||
lspconfig["jsonls"].setup({
|
lspconfig["jsonls"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "json" },
|
filetypes = { "json" },
|
||||||
})
|
})
|
||||||
|
|
||||||
lspconfig["pyright"].setup({
|
lspconfig["pyright"].setup({
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
flags = lsp_flags,
|
filetypes = { "py" },
|
||||||
filetypes = { "py" },
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- configure html server
|
-- configure html server
|
||||||
lspconfig["html"].setup({
|
lspconfig["html"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "html" },
|
filetypes = { "html" },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- configure css server
|
-- configure css server
|
||||||
lspconfig["cssls"].setup({
|
lspconfig["cssls"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- configure tailwindcss server
|
-- configure tailwindcss server
|
||||||
lspconfig["tailwindcss"].setup({
|
lspconfig["tailwindcss"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- configure emmet language server
|
-- configure emmet language server
|
||||||
lspconfig["emmet_ls"].setup({
|
lspconfig["emmet_ls"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
||||||
})
|
})
|
||||||
|
|
||||||
lspconfig["eslint"].setup({
|
lspconfig["eslint"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- rust
|
-- rust
|
||||||
lspconfig["rust_analyzer"].setup({
|
lspconfig["rust_analyzer"].setup({
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
flags = lsp_flags,
|
-- Server-specific settings...
|
||||||
-- Server-specific settings...
|
settings = {
|
||||||
settings = {
|
["rust-analyzer"] = {
|
||||||
["rust-analyzer"] = {
|
-- enable clippy on save
|
||||||
-- enable clippy on save
|
checkOnSave = {
|
||||||
checkOnSave = {
|
command = "clippy",
|
||||||
command = "clippy",
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
lspconfig["yamlls"].setup({
|
lspconfig["yamlls"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "yml", "yaml" },
|
filetypes = { "yml", "yaml" },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- -- configure lua server (with special settings)
|
-- -- configure lua server (with special settings)
|
||||||
lspconfig["lua_ls"].setup({
|
lspconfig["lua_ls"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
settings = { -- custom settings for lua
|
filetypes = { "lua" },
|
||||||
Lua = {
|
|
||||||
-- make the language server recognize "vim" global
|
|
||||||
diagnostics = {
|
|
||||||
globals = { "vim" },
|
|
||||||
},
|
|
||||||
workspace = {
|
|
||||||
-- make language server aware of runtime files
|
|
||||||
library = {
|
|
||||||
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
|
||||||
[vim.fn.stdpath("config") .. "/lua"] = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
filetypes = { "lua" },
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- lspconfig["phpactor"].setup({
|
-- lspconfig["phpactor"].setup({
|
||||||
|
@ -217,17 +174,25 @@ lspconfig["lua_ls"].setup({
|
||||||
-- })
|
-- })
|
||||||
|
|
||||||
lspconfig["intelephense"].setup({
|
lspconfig["intelephense"].setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = { "php" },
|
filetypes = { "php" },
|
||||||
})
|
})
|
||||||
|
|
||||||
lspconfig["slint_lsp"].setup({
|
lspconfig["slint_lsp"].setup({
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
filetypes = { "slint" },
|
filetypes = { "slint" },
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.g.nvim_phpcs_config_phpcs_path = 'phpcs'
|
vim.g.nvim_phpcs_config_phpcs_path = 'phpcs'
|
||||||
vim.g.nvim_phpcs_config_phpcbf_path = 'phpcbf'
|
vim.g.nvim_phpcs_config_phpcbf_path = 'phpcbf'
|
||||||
vim.g.nvim_phpcs_config_phpcs_standard = "/home/mace/repos/configs/phpcs.xml"
|
local phpcs_config = "/home/mace/repos/configs/phpcs.xml"
|
||||||
|
local phpcs_config_new = "/home/mace/repos/dotfiles/phpcs.xml"
|
||||||
|
|
||||||
|
if vim.loop.fs_stat(phpcs_config_new) then
|
||||||
|
vim.g.nvim_phpcs_config_phpcs_standard = phpcs_config_new
|
||||||
|
end
|
||||||
|
if vim.loop.fs_stat(phpcs_config) then
|
||||||
|
vim.g.nvim_phpcs_config_phpcs_standard = phpcs_config
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue