mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-22 00:49:01 +02:00
fix: mason lsp config
This commit is contained in:
parent
b04a8d86c6
commit
60bb763639
3 changed files with 232 additions and 130 deletions
|
@ -3,57 +3,57 @@ vim.opt_local.shiftwidth = 4
|
||||||
vim.opt_local.tabstop = 4
|
vim.opt_local.tabstop = 4
|
||||||
vim.opt_local.softtabstop = 4
|
vim.opt_local.softtabstop = 4
|
||||||
|
|
||||||
local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
|
-- local status_ok, configs = pcall(require, "nvim-treesitter.configs")
|
||||||
if not lspconfig_status_ok then
|
-- if not status_ok then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
|
-- local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
|
||||||
if not status_ok then
|
-- if not lspconfig_status_ok then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local mason_ok, mason_lsp = pcall(require, "mason-lspconfig")
|
-- local mason_ok, mason_lsp = pcall(require, "mason-lspconfig")
|
||||||
if not mason_ok then
|
-- if not mason_ok then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
|
|
||||||
mason_lsp.setup({
|
-- mason_lsp.setup({
|
||||||
ensure_installed = { "kotlin_language_server" },
|
-- ensure_installed = { "kotlin_language_server" },
|
||||||
automatic_installation = true,
|
-- 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,
|
||||||
cmd = { "kotlin-language-server" },
|
-- cmd = { "kotlin-language-server" },
|
||||||
filetypes = { "kotlin" },
|
-- filetypes = { "kotlin" },
|
||||||
root_dir = require("lspconfig.util").root_pattern(
|
-- root_dir = require("lspconfig.util").root_pattern(
|
||||||
"build.gradle.kts",
|
-- "build.gradle.kts",
|
||||||
"build.gradle",
|
-- "build.gradle",
|
||||||
"settings.gradle",
|
-- "settings.gradle",
|
||||||
"gradlew",
|
-- "gradlew",
|
||||||
"pom.xml",
|
-- "pom.xml",
|
||||||
"build.gradle.kts",
|
-- "build.gradle.kts",
|
||||||
"build.kts",
|
-- "build.kts",
|
||||||
".git"
|
-- ".git"
|
||||||
),
|
-- ),
|
||||||
})
|
-- })
|
||||||
|
|
||||||
configs.setup({
|
-- configs.setup({
|
||||||
ensure_installed = { "kotlin" }, -- pastikan parser TypeScript terinstal
|
-- ensure_installed = { "kotlin" }, -- pastikan parser TypeScript terinstal
|
||||||
highlight = {
|
-- highlight = {
|
||||||
enable = true, -- aktifkan highlight berbasis treesitter
|
-- enable = true, -- aktifkan highlight berbasis treesitter
|
||||||
additional_vim_regex_highlighting = false,
|
-- additional_vim_regex_highlighting = false,
|
||||||
},
|
-- },
|
||||||
rainbow = {
|
-- rainbow = {
|
||||||
enable = false,
|
-- enable = false,
|
||||||
},
|
-- },
|
||||||
incremental_selection = { enable = true },
|
-- incremental_selection = { enable = true },
|
||||||
indent = { enable = true, disable = { "python", "css" } },
|
-- indent = { enable = true, disable = { "python", "css" } },
|
||||||
autopairs = {
|
-- autopairs = {
|
||||||
enable = true,
|
-- enable = true,
|
||||||
},
|
-- },
|
||||||
})
|
-- })
|
||||||
|
--
|
||||||
require("nvim-ts-autotag").setup()
|
-- require("nvim-ts-autotag").setup()
|
||||||
|
|
|
@ -1,89 +1,89 @@
|
||||||
local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
|
-- local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
|
||||||
if not lspconfig_status_ok then
|
-- if not lspconfig_status_ok then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local function idxOf(array, value)
|
-- local function idxOf(array, value)
|
||||||
for i, v in ipairs(array) do
|
-- for i, v in ipairs(array) do
|
||||||
if v == value then
|
-- if v == value then
|
||||||
return i
|
-- return i
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
return nil
|
-- return nil
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local unregis_lsp = {}
|
-- local unregis_lsp = {}
|
||||||
local data_ok, unregis = pcall(require, "core.config")
|
-- local data_ok, unregis = pcall(require, "core.config")
|
||||||
if data_ok then
|
-- if data_ok then
|
||||||
if unregis.unregister_lsp ~= nil then
|
-- if unregis.unregister_lsp ~= nil then
|
||||||
unregis_lsp = unregis.unregister_lsp
|
-- unregis_lsp = unregis.unregister_lsp
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local idxts = idxOf(unregis_lsp, "tsserver")
|
-- local idxts = idxOf(unregis_lsp, "tsserver")
|
||||||
if idxts ~= nil then
|
-- if idxts ~= nil then
|
||||||
lspconfig.tsserver.setup({
|
-- lspconfig.tsserver.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,
|
||||||
-- add cmd
|
-- -- add cmd
|
||||||
cmd = { "typescript-language-server", "--stdio" },
|
-- cmd = { "typescript-language-server", "--stdio" },
|
||||||
-- add file type support
|
-- -- add file type support
|
||||||
filetypes = {
|
-- filetypes = {
|
||||||
"javascript",
|
-- "javascript",
|
||||||
"javascriptreact",
|
-- "javascriptreact",
|
||||||
"javascript.jsx",
|
-- "javascript.jsx",
|
||||||
"typescript",
|
-- "typescript",
|
||||||
"typescriptreact",
|
-- "typescriptreact",
|
||||||
"typescript.tsx",
|
-- "typescript.tsx",
|
||||||
},
|
-- },
|
||||||
-- add dynamic root dir support
|
-- -- add dynamic root dir support
|
||||||
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
-- root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||||
init_options = {
|
-- init_options = {
|
||||||
hostInfo = "neovim",
|
-- hostInfo = "neovim",
|
||||||
},
|
-- },
|
||||||
})
|
-- })
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local idxemmet = idxOf(unregis_lsp, "emmet_ls")
|
-- local idxemmet = idxOf(unregis_lsp, "emmet_ls")
|
||||||
if idxemmet ~= nil then
|
-- if idxemmet ~= nil then
|
||||||
lspconfig.emmet_ls.setup({
|
-- lspconfig.emmet_ls.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,
|
||||||
-- add cmd
|
-- -- add cmd
|
||||||
cmd = { "emmet-ls", "-c", "--stdio" },
|
-- cmd = { "emmet-ls", "-c", "--stdio" },
|
||||||
-- add file type support
|
-- -- add file type support
|
||||||
filetypes = {
|
-- filetypes = {
|
||||||
"javascript",
|
-- "javascript",
|
||||||
"javascriptreact",
|
-- "javascriptreact",
|
||||||
"javascript.jsx",
|
-- "javascript.jsx",
|
||||||
"typescript",
|
-- "typescript",
|
||||||
"typescriptreact",
|
-- "typescriptreact",
|
||||||
"typescript.tsx",
|
-- "typescript.tsx",
|
||||||
},
|
-- },
|
||||||
-- add dynamic root dir support
|
-- -- add dynamic root dir support
|
||||||
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
-- root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||||
})
|
-- })
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local idxeslint = idxOf(unregis_lsp, "eslint")
|
-- local idxeslint = idxOf(unregis_lsp, "eslint")
|
||||||
if idxeslint ~= nil then
|
-- if idxeslint ~= nil then
|
||||||
lspconfig.eslint.setup({
|
-- lspconfig.eslint.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,
|
||||||
-- add cmd
|
-- -- add cmd
|
||||||
cmd = { "vscode-eslint-language-server", "--stdio" }, -- add file type support
|
-- cmd = { "vscode-eslint-language-server", "--stdio" }, -- add file type support
|
||||||
filetypes = {
|
-- filetypes = {
|
||||||
"javascript",
|
-- "javascript",
|
||||||
"javascriptreact",
|
-- "javascriptreact",
|
||||||
"javascript.jsx",
|
-- "javascript.jsx",
|
||||||
"typescript",
|
-- "typescript",
|
||||||
"typescriptreact",
|
-- "typescriptreact",
|
||||||
"typescript.tsx",
|
-- "typescript.tsx",
|
||||||
},
|
-- },
|
||||||
-- add dynamic root dir support
|
-- -- add dynamic root dir support
|
||||||
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
-- root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||||
})
|
-- })
|
||||||
end
|
-- 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
|
||||||
|
|
|
@ -115,4 +115,106 @@ require("mason-lspconfig").setup_handlers({
|
||||||
-- },
|
-- },
|
||||||
-- })
|
-- })
|
||||||
-- end,
|
-- end,
|
||||||
|
["tsserver"] = function()
|
||||||
|
lspconfig.tsserver.setup({
|
||||||
|
on_attach = require("user.lsp.handlers").on_attach,
|
||||||
|
capabilities = require("user.lsp.handlers").capabilities,
|
||||||
|
-- add cmd
|
||||||
|
cmd = { "typescript-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"),
|
||||||
|
init_options = {
|
||||||
|
hostInfo = "neovim",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
["emmet_ls"] = function()
|
||||||
|
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",
|
||||||
|
-- "astro",
|
||||||
|
-- "css",
|
||||||
|
-- "eruby",
|
||||||
|
-- "html",
|
||||||
|
-- "htmldjango",
|
||||||
|
-- "less",
|
||||||
|
-- "pug",
|
||||||
|
-- "sass",
|
||||||
|
-- "scss",
|
||||||
|
-- "svelte",
|
||||||
|
-- "vue" -- },
|
||||||
|
-- add dynamic root dir support
|
||||||
|
root_dir = require("lspconfig.util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
["eslint"] = function()
|
||||||
|
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,
|
||||||
|
["kotlin_language_server"] = function()
|
||||||
|
lspconfig.kotlin_language_server.setup({
|
||||||
|
on_attach = require("user.lsp.handlers").on_attach,
|
||||||
|
capabilities = require("user.lsp.handlers").capabilities,
|
||||||
|
cmd = { "kotlin-language-server" },
|
||||||
|
filetypes = { "kotlin" },
|
||||||
|
root_dir = require("lspconfig.util").root_pattern(
|
||||||
|
"build.gradle.kts",
|
||||||
|
"build.gradle",
|
||||||
|
"settings.gradle",
|
||||||
|
"gradlew",
|
||||||
|
"pom.xml",
|
||||||
|
"build.gradle.kts",
|
||||||
|
"build.kts",
|
||||||
|
".git"
|
||||||
|
),
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
["clangd"] = function()
|
||||||
|
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(),
|
||||||
|
})
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue