mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 08:35:48 +02:00
add: unregister lsp
This commit is contained in:
parent
7efd41b1ba
commit
b04a8d86c6
3 changed files with 163 additions and 53 deletions
51
ftplugin/cpp.lua
Normal file
51
ftplugin/cpp.lua
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
-- local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
|
||||||
|
-- if not lspconfig_status_ok then
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- local status_ok, configs = pcall(require, "nvim-treesitter.configs")
|
||||||
|
-- if not status_ok then
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- local mason_ok, mason_lsp = pcall(require, "mason-lspconfig")
|
||||||
|
-- if not mason_ok then
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- mason_lsp.setup({
|
||||||
|
-- ensure_installed = { "clangd" },
|
||||||
|
-- automatic_installation = true,
|
||||||
|
-- })
|
||||||
|
--
|
||||||
|
-- lspconfig.clangd.setup({
|
||||||
|
-- on_attach = require("user.lsp.handlers").on_attach,
|
||||||
|
-- capabilities = require("user.lsp.handlers").capabilities,
|
||||||
|
-- root_dir = require("lspconfig.util").root_pattern(
|
||||||
|
-- "build",
|
||||||
|
-- "compile_commands.json",
|
||||||
|
-- ".git",
|
||||||
|
-- "mvnw",
|
||||||
|
-- "gradlew",
|
||||||
|
-- "pom.xml",
|
||||||
|
-- "build.gradle"
|
||||||
|
-- ) or vim.loop.cwd() or vim.fn.getcwd(),
|
||||||
|
-- })
|
||||||
|
--
|
||||||
|
-- configs.setup({
|
||||||
|
-- ensure_installed = { "cpp" }, -- pastikan parser TypeScript terinstal
|
||||||
|
-- highlight = {
|
||||||
|
-- enable = true, -- aktifkan highlight berbasis treesitter
|
||||||
|
-- additional_vim_regex_highlighting = false,
|
||||||
|
-- },
|
||||||
|
-- rainbow = {
|
||||||
|
-- enable = false,
|
||||||
|
-- },
|
||||||
|
-- incremental_selection = { enable = true },
|
||||||
|
-- indent = { enable = true, disable = { "python", "css" } },
|
||||||
|
-- autopairs = {
|
||||||
|
-- enable = true,
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
--
|
||||||
|
-- require("nvim-ts-autotag").setup()
|
|
@ -8,6 +8,21 @@ if not lspconfig_status_ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local mason_ok, mason_lsp = pcall(require, "mason-lspconfig")
|
||||||
|
if not mason_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
mason_lsp.setup({
|
||||||
|
ensure_installed = { "kotlin_language_server" },
|
||||||
|
automatic_installation = true,
|
||||||
|
})
|
||||||
|
|
||||||
lspconfig.kotlin_language_server.setup({
|
lspconfig.kotlin_language_server.setup({
|
||||||
on_attach = require("user.lsp.handlers").on_attach,
|
on_attach = require("user.lsp.handlers").on_attach,
|
||||||
capabilities = require("user.lsp.handlers").capabilities,
|
capabilities = require("user.lsp.handlers").capabilities,
|
||||||
|
@ -24,3 +39,21 @@ lspconfig.kotlin_language_server.setup({
|
||||||
".git"
|
".git"
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
configs.setup({
|
||||||
|
ensure_installed = { "kotlin" }, -- pastikan parser TypeScript terinstal
|
||||||
|
highlight = {
|
||||||
|
enable = true, -- aktifkan highlight berbasis treesitter
|
||||||
|
additional_vim_regex_highlighting = false,
|
||||||
|
},
|
||||||
|
rainbow = {
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
incremental_selection = { enable = true },
|
||||||
|
indent = { enable = true, disable = { "python", "css" } },
|
||||||
|
autopairs = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
require("nvim-ts-autotag").setup()
|
||||||
|
|
|
@ -3,61 +3,87 @@ if not lspconfig_status_ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
lspconfig.tsserver.setup({
|
local function idxOf(array, value)
|
||||||
on_attach = require("user.lsp.handlers").on_attach,
|
for i, v in ipairs(array) do
|
||||||
capabilities = require("user.lsp.handlers").capabilities,
|
if v == value then
|
||||||
-- add cmd
|
return i
|
||||||
cmd = { "typescript-language-server", "--stdio" },
|
end
|
||||||
-- add file type support
|
end
|
||||||
filetypes = {
|
return nil
|
||||||
"javascript",
|
end
|
||||||
"javascriptreact",
|
|
||||||
"javascript.jsx",
|
|
||||||
"typescript",
|
|
||||||
"typescriptreact",
|
|
||||||
"typescript.tsx",
|
|
||||||
},
|
|
||||||
-- add dynamic root dir support
|
|
||||||
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
|
||||||
init_options = {
|
|
||||||
hostInfo = "neovim",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig.emmet_ls.setup({
|
local unregis_lsp = {}
|
||||||
on_attach = require("user.lsp.handlers").on_attach,
|
local data_ok, unregis = pcall(require, "core.config")
|
||||||
capabilities = require("user.lsp.handlers").capabilities,
|
if data_ok then
|
||||||
-- add cmd
|
if unregis.unregister_lsp ~= nil then
|
||||||
cmd = { "emmet-ls", "-c", "--stdio" },
|
unregis_lsp = unregis.unregister_lsp
|
||||||
-- add file type support
|
end
|
||||||
filetypes = {
|
end
|
||||||
"javascript",
|
|
||||||
"javascriptreact",
|
|
||||||
"javascript.jsx",
|
|
||||||
"typescript",
|
|
||||||
"typescriptreact",
|
|
||||||
"typescript.tsx",
|
|
||||||
},
|
|
||||||
-- add dynamic root dir support
|
|
||||||
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig.eslint.setup({
|
local idxts = idxOf(unregis_lsp, "tsserver")
|
||||||
on_attach = require("user.lsp.handlers").on_attach,
|
if idxts ~= nil then
|
||||||
capabilities = require("user.lsp.handlers").capabilities,
|
lspconfig.tsserver.setup({
|
||||||
-- add cmd
|
on_attach = require("user.lsp.handlers").on_attach,
|
||||||
cmd = { "vscode-eslint-language-server", "--stdio" }, -- add file type support
|
capabilities = require("user.lsp.handlers").capabilities,
|
||||||
filetypes = {
|
-- add cmd
|
||||||
"javascript",
|
cmd = { "typescript-language-server", "--stdio" },
|
||||||
"javascriptreact",
|
-- add file type support
|
||||||
"javascript.jsx",
|
filetypes = {
|
||||||
"typescript",
|
"javascript",
|
||||||
"typescriptreact",
|
"javascriptreact",
|
||||||
"typescript.tsx",
|
"javascript.jsx",
|
||||||
},
|
"typescript",
|
||||||
-- add dynamic root dir support
|
"typescriptreact",
|
||||||
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
"typescript.tsx",
|
||||||
})
|
},
|
||||||
|
-- add dynamic root dir support
|
||||||
|
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||||
|
init_options = {
|
||||||
|
hostInfo = "neovim",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local idxemmet = idxOf(unregis_lsp, "emmet_ls")
|
||||||
|
if idxemmet ~= nil then
|
||||||
|
lspconfig.emmet_ls.setup({
|
||||||
|
on_attach = require("user.lsp.handlers").on_attach,
|
||||||
|
capabilities = require("user.lsp.handlers").capabilities,
|
||||||
|
-- add cmd
|
||||||
|
cmd = { "emmet-ls", "-c", "--stdio" },
|
||||||
|
-- add file type support
|
||||||
|
filetypes = {
|
||||||
|
"javascript",
|
||||||
|
"javascriptreact",
|
||||||
|
"javascript.jsx",
|
||||||
|
"typescript",
|
||||||
|
"typescriptreact",
|
||||||
|
"typescript.tsx",
|
||||||
|
},
|
||||||
|
-- add dynamic root dir support
|
||||||
|
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local idxeslint = idxOf(unregis_lsp, "eslint")
|
||||||
|
if idxeslint ~= nil then
|
||||||
|
lspconfig.eslint.setup({
|
||||||
|
on_attach = require("user.lsp.handlers").on_attach,
|
||||||
|
capabilities = require("user.lsp.handlers").capabilities,
|
||||||
|
-- add cmd
|
||||||
|
cmd = { "vscode-eslint-language-server", "--stdio" }, -- add file type support
|
||||||
|
filetypes = {
|
||||||
|
"javascript",
|
||||||
|
"javascriptreact",
|
||||||
|
"javascript.jsx",
|
||||||
|
"typescript",
|
||||||
|
"typescriptreact",
|
||||||
|
"typescript.tsx",
|
||||||
|
},
|
||||||
|
-- add dynamic root dir support
|
||||||
|
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
|
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue