update
This commit is contained in:
parent
132854cc0c
commit
5793c3da7f
9 changed files with 176 additions and 129 deletions
|
|
@ -1,13 +1,33 @@
|
|||
-- Load language server configuration
|
||||
-- 1. Setup Mason first
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
-- Remove "jdtls" from here to prevent the 'enable' (nil value) crash
|
||||
ensure_installed = {
|
||||
"pyright",
|
||||
"ts_ls",
|
||||
"marksman",
|
||||
"kotlin_language_server",
|
||||
"graphql"
|
||||
},
|
||||
})
|
||||
|
||||
-- 2. Global LSP Attach (The modern way to handle keymaps)
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
-- 3. Load your modernized server configs
|
||||
-- These files should now use vim.lsp.config and vim.lsp.enable
|
||||
require("user.lsp_servers.pyright")
|
||||
require("user.lsp_servers.ts_ls")
|
||||
require("user.lsp_servers.jdtls")
|
||||
require("user.lsp_servers.marksman")
|
||||
require("user.lsp_servers.kotlin_ls")
|
||||
require("user.lsp_servers.graphql")
|
||||
|
||||
-- Mason setup
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = { "pyright", "ts_ls", "jdtls", "marksman", "kotlin_language_server" }, -- Ensure Kotlin LSP is installed
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,21 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
-- 1. Configuration
|
||||
vim.lsp.config('graphql', {
|
||||
cmd = { "graphql-lsp", "server", "-m", "stream" },
|
||||
filetypes = { "graphql", "gql", "javascript", "typescript", "typescriptreact", "javascriptreact" },
|
||||
|
||||
-- This ensures GraphQL only starts if it finds a config file
|
||||
root_markers = {
|
||||
".graphqlrc",
|
||||
".graphqlrc.json",
|
||||
".graphqlrc.yaml",
|
||||
".graphqlrc.yml",
|
||||
"graphql.config.json",
|
||||
"graphql.config.yaml",
|
||||
"graphql.config.yml"
|
||||
},
|
||||
|
||||
lspconfig.graphql.setup({
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||
filetypes = { "graphql", "gql", "javascript", "typescript" },
|
||||
})
|
||||
|
||||
-- 2. Enable the server
|
||||
vim.lsp.enable('graphql')
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
-- 1. Setup paths and capabilities
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
-- Java binary (ensure it's Java 21)
|
||||
local java_bin = "/usr/lib/jvm/java-21-openjdk/bin/java"
|
||||
|
||||
-- Find JDTLS and Lombok paths dynamically
|
||||
local jdtls_path = "/home/prabhat/.local/share/nvim/mason/packages/jdtls"
|
||||
local jdtls_path = vim.fn.stdpath("data") .. "/mason/packages/jdtls"
|
||||
local jdtls_launcher_jar = vim.fn.glob(jdtls_path .. "/plugins/org.eclipse.equinox.launcher_*.jar")
|
||||
local lombok_jar = vim.fn.glob(jdtls_path .. "/lombok.jar")
|
||||
local lombok_jar = jdtls_path .. "/lombok.jar"
|
||||
|
||||
lspconfig.jdtls.setup({
|
||||
-- 2. Define the configuration
|
||||
vim.lsp.config('jdtls', {
|
||||
cmd = {
|
||||
java_bin,
|
||||
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
||||
|
|
@ -17,22 +14,19 @@ lspconfig.jdtls.setup({
|
|||
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
||||
"-Dlog.protocol=true",
|
||||
"-Dlog.level=INFO",
|
||||
"-Xmx2G", -- Max heap size
|
||||
"-Xms256m", -- Min heap size
|
||||
"-Xmx2G",
|
||||
"-Xms256m",
|
||||
"--add-modules=ALL-SYSTEM",
|
||||
"--add-opens", "java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
|
||||
"-javaagent:" .. lombok_jar, -- Lombok support
|
||||
"-jar", jdtls_launcher_jar, -- JDTLS launcher
|
||||
"-javaagent:" .. lombok_jar,
|
||||
"-jar", jdtls_launcher_jar,
|
||||
"-configuration", jdtls_path .. "/config_linux",
|
||||
"-data", vim.fn.stdpath("data") .. "/jdtls-workspace/" .. vim.fn.fnamemodify(vim.loop.cwd(), ":p:h:t"),
|
||||
"-data", vim.fn.stdpath("data") .. "/jdtls-workspace/" .. vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t"),
|
||||
},
|
||||
capabilities = capabilities,
|
||||
root_dir = function()
|
||||
return vim.fs.dirname(
|
||||
vim.fs.find({ ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }, { upward = true })[1]
|
||||
)
|
||||
end,
|
||||
-- In 0.11, use root_markers instead of a root_dir function
|
||||
root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" },
|
||||
settings = {
|
||||
java = {
|
||||
completion = {
|
||||
|
|
@ -51,23 +45,10 @@ lspconfig.jdtls.setup({
|
|||
},
|
||||
},
|
||||
import = {
|
||||
exclusions = {
|
||||
"**/internal/**",
|
||||
},
|
||||
maven = {
|
||||
enabled = true,
|
||||
downloadSources = true,
|
||||
},
|
||||
gradle = {
|
||||
enabled = true,
|
||||
},
|
||||
maven = { enabled = true, downloadSources = true },
|
||||
gradle = { enabled = true },
|
||||
settings = {
|
||||
importOrder = {
|
||||
"java",
|
||||
"javax",
|
||||
"org",
|
||||
"com",
|
||||
},
|
||||
importOrder = { "java", "javax", "org", "com" },
|
||||
},
|
||||
},
|
||||
inlayHints = {
|
||||
|
|
@ -83,3 +64,5 @@ lspconfig.jdtls.setup({
|
|||
},
|
||||
})
|
||||
|
||||
-- 3. Enable the server
|
||||
vim.lsp.enable('jdtls')
|
||||
|
|
|
|||
|
|
@ -1,24 +1,15 @@
|
|||
-- lua/user/lsp_servers/kotlin_ls.lua
|
||||
-- 1. Configuration
|
||||
vim.lsp.config('kotlin_language_server', {
|
||||
cmd = { "kotlin-language-server" },
|
||||
filetypes = { "kotlin" },
|
||||
-- Kotlin projects are usually defined by build files or git
|
||||
root_markers = { "settings.gradle", "settings.gradle.kts", "pom.xml", ".git" },
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- Setup the Kotlin language server
|
||||
lspconfig.kotlin_language_server.setup({
|
||||
cmd = { "kotlin-language-server" }, -- The command to start the server
|
||||
on_attach = function(client, bufnr)
|
||||
-- Key mappings for LSP functions
|
||||
local opts = { noremap = true, silent = true }
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
|
||||
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>rn", "<Cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
end,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
-- flags in lspconfig setup are now part of the general config table
|
||||
init_options = {
|
||||
debounceTextChanges = 150,
|
||||
},
|
||||
|
||||
settings = {
|
||||
kotlin = {
|
||||
linting = { enabled = true },
|
||||
|
|
@ -26,3 +17,6 @@ lspconfig.kotlin_language_server.setup({
|
|||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- 2. Enable the server
|
||||
vim.lsp.enable('kotlin_language_server')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
-- Setup for Markdown LSP (Marksman)
|
||||
lspconfig.marksman.setup({
|
||||
-- Add additional settings here
|
||||
filetypes = { "markdown", "md" },
|
||||
-- 1. Configuration
|
||||
vim.lsp.config('marksman', {
|
||||
cmd = { "marksman", "server" },
|
||||
filetypes = { "markdown", "markdown.md" },
|
||||
-- Marksman looks for a .marksman.toml or a .git directory to define the project root
|
||||
root_markers = { ".marksman.toml", ".git" },
|
||||
})
|
||||
|
||||
-- 2. Enable the server
|
||||
-- Note: You don't need to redefine the LspAttach autocmd here
|
||||
-- if you already added it to your pyright or ts_ls files.
|
||||
vim.lsp.enable('marksman')
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
-- Define the configuration for pyright
|
||||
vim.lsp.config('pyright', {
|
||||
-- The command to start the server (usually the same as lspconfig's default)
|
||||
cmd = { "pyright-langserver", "--stdio" },
|
||||
filetypes = { "python" },
|
||||
root_markers = { ".git", "pyproject.toml", "setup.py", "requirements.txt" },
|
||||
|
||||
lspconfig.pyright.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
-- Custom keymaps and commands for pyright
|
||||
end,
|
||||
-- Your custom settings move here
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
|
|
@ -13,3 +15,18 @@ lspconfig.pyright.setup({
|
|||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Handle the on_attach logic
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if client and client.name == 'pyright' then
|
||||
local bufnr = args.buf
|
||||
-- Your custom keymaps and commands for pyright go here
|
||||
-- Example: vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = bufnr })
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Finally, enable the server
|
||||
vim.lsp.enable('pyright')
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
|
||||
lspconfig.ts_ls.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
-- Custom keymaps and commands for tsserver
|
||||
local opts = { noremap = true, silent = true }
|
||||
-- Example key mappings
|
||||
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", "<leader>rn", "<Cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
end,
|
||||
-- 1. Configuration
|
||||
vim.lsp.config('ts_ls', {
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
filetypes = {
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
|
|
@ -17,10 +9,10 @@ lspconfig.ts_ls.setup({
|
|||
"javascriptreact",
|
||||
"javascript.jsx",
|
||||
},
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
root_dir = lspconfig.util.root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||
-- In 0.11, root_markers replaces root_dir logic
|
||||
root_markers = { "package.json", "tsconfig.json", "jsconfig.json", ".git" },
|
||||
settings = {
|
||||
-- Enable document formatting
|
||||
javascript = {
|
||||
format = {
|
||||
enable = true,
|
||||
insertSpaceAfterCommaDelimiter = true,
|
||||
|
|
@ -28,14 +20,34 @@ lspconfig.ts_ls.setup({
|
|||
insertSpaceBeforeAndAfterOperator = true,
|
||||
indentStyle = "smart",
|
||||
indentSize = 2,
|
||||
wrapLineLength = 120,
|
||||
},
|
||||
-- Diagnostics and completion settings
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
},
|
||||
completions = {
|
||||
typescript = {
|
||||
format = {
|
||||
enable = true,
|
||||
insertSpaceAfterCommaDelimiter = true,
|
||||
insertSpaceAfterSemicolon = true,
|
||||
insertSpaceBeforeAndAfterOperator = true,
|
||||
indentStyle = "smart",
|
||||
indentSize = 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- 2. Global LspAttach for Keymaps
|
||||
-- This works for all servers, so you only need to define it once (e.g., in user/lsp.lua)
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf, noremap = true, silent = true }
|
||||
|
||||
-- Modern way to set keymaps using the lua function directly
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
-- 3. Enable the server
|
||||
vim.lsp.enable('ts_ls')
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
require("nvim-treesitter.configs").setup({
|
||||
require("nvim-treesitter").setup({
|
||||
ensure_installed = {
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
|
|
|
|||
BIN
nvim-macos-x86_64/bin/nvim
Executable file
BIN
nvim-macos-x86_64/bin/nvim
Executable file
Binary file not shown.
Loading…
Reference in a new issue