update
This commit is contained in:
parent
132854cc0c
commit
203159cee6
8 changed files with 183 additions and 190 deletions
12
init.lua
12
init.lua
|
|
@ -7,7 +7,7 @@ require("user.autopairs")
|
|||
require("user.telescope")
|
||||
require("user.gruvbox")
|
||||
require("user.lsp")
|
||||
require("user.treesitter")
|
||||
-- require("user.treesitter")
|
||||
require("user.terminal")
|
||||
require("user.markdown")
|
||||
require("user.autocmds")
|
||||
|
|
@ -41,7 +41,14 @@ return require("packer").startup(function(use)
|
|||
use("jose-elias-alvarez/nvim-lsp-ts-utils")
|
||||
|
||||
-- Treesitter
|
||||
use("nvim-treesitter/nvim-treesitter")
|
||||
-- use("nvim-treesitter/nvim-treesitter")
|
||||
use({
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
run = ":TSUpdate",
|
||||
config = function()
|
||||
require("user.treesitter") -- Load the config ONLY after plugin is loaded
|
||||
end,
|
||||
})
|
||||
|
||||
-- Auto pairs
|
||||
use("windwp/nvim-autopairs")
|
||||
|
|
@ -102,3 +109,4 @@ return require("packer").startup(function(use)
|
|||
end,
|
||||
})
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
-- lua/user/lsp_servers/graphql.lua
|
||||
|
||||
lspconfig.graphql.setup({
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||
vim.lsp.config("graphql", {
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
filetypes = { "graphql", "gql", "javascript", "typescript" },
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,85 +1,75 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
-- lua/user/lsp_servers/jdtls.lua
|
||||
|
||||
-- Get capabilities for nvim-cmp
|
||||
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
|
||||
-- JDTLS paths (Mason-managed)
|
||||
local jdtls_path = "/home/prabhat/.local/share/nvim/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")
|
||||
|
||||
lspconfig.jdtls.setup({
|
||||
cmd = {
|
||||
java_bin,
|
||||
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
||||
"-Dosgi.bundles.defaultStartLevel=4",
|
||||
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
||||
"-Dlog.protocol=true",
|
||||
"-Dlog.level=INFO",
|
||||
"-Xmx2G", -- Max heap size
|
||||
"-Xms256m", -- Min heap size
|
||||
"--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
|
||||
"-configuration", jdtls_path .. "/config_linux",
|
||||
"-data", vim.fn.stdpath("data") .. "/jdtls-workspace/" .. vim.fn.fnamemodify(vim.loop.cwd(), ":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,
|
||||
settings = {
|
||||
java = {
|
||||
completion = {
|
||||
favoriteStaticMembers = {
|
||||
"org.junit.jupiter.api.Assertions.*",
|
||||
"org.mockito.Mockito.*",
|
||||
"java.util.Objects.requireNonNull",
|
||||
"java.util.Objects.requireNonNullElse",
|
||||
},
|
||||
filteredTypes = {
|
||||
"com.sun.*",
|
||||
"io.micrometer.shaded.*",
|
||||
"java.awt.*",
|
||||
"jdk.*",
|
||||
"sun.*",
|
||||
},
|
||||
},
|
||||
import = {
|
||||
exclusions = {
|
||||
"**/internal/**",
|
||||
},
|
||||
maven = {
|
||||
enabled = true,
|
||||
downloadSources = true,
|
||||
},
|
||||
gradle = {
|
||||
enabled = true,
|
||||
},
|
||||
settings = {
|
||||
importOrder = {
|
||||
"java",
|
||||
"javax",
|
||||
"org",
|
||||
"com",
|
||||
},
|
||||
},
|
||||
},
|
||||
inlayHints = {
|
||||
parameterNames = { enabled = "all" },
|
||||
},
|
||||
format = {
|
||||
enabled = true,
|
||||
settings = {
|
||||
url = jdtls_path .. "/eclipse-formatter.xml",
|
||||
},
|
||||
},
|
||||
-- Setup JDTLS
|
||||
vim.lsp.config("jdtls", {
|
||||
cmd = {
|
||||
java_bin,
|
||||
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
||||
"-Dosgi.bundles.defaultStartLevel=4",
|
||||
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
||||
"-Dlog.protocol=true",
|
||||
"-Dlog.level=INFO",
|
||||
"-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,
|
||||
"-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"),
|
||||
},
|
||||
|
||||
capabilities = capabilities,
|
||||
|
||||
root_dir = function()
|
||||
local root_files = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }
|
||||
local found = vim.fs.find(root_files, { upward = true })[1]
|
||||
return found and vim.fs.dirname(found) or vim.loop.cwd()
|
||||
end,
|
||||
|
||||
settings = {
|
||||
java = {
|
||||
completion = {
|
||||
favoriteStaticMembers = {
|
||||
"org.junit.jupiter.api.Assertions.*",
|
||||
"org.mockito.Mockito.*",
|
||||
"java.util.Objects.requireNonNull",
|
||||
"java.util.Objects.requireNonNullElse",
|
||||
},
|
||||
filteredTypes = {
|
||||
"com.sun.*",
|
||||
"io.micrometer.shaded.*",
|
||||
"java.awt.*",
|
||||
"jdk.*",
|
||||
"sun.*",
|
||||
},
|
||||
},
|
||||
import = {
|
||||
exclusions = { "**/internal/**" },
|
||||
maven = { enabled = true, downloadSources = true },
|
||||
gradle = { enabled = true },
|
||||
settings = {
|
||||
importOrder = { "java", "javax", "org", "com" },
|
||||
},
|
||||
},
|
||||
inlayHints = { parameterNames = { enabled = "all" } },
|
||||
format = {
|
||||
enabled = true,
|
||||
settings = { url = jdtls_path .. "/eclipse-formatter.xml" },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,25 @@
|
|||
-- lua/user/lsp_servers/kotlin_ls.lua
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
vim.lsp.config("kotlin_language_server", {
|
||||
cmd = { "kotlin-language-server" },
|
||||
|
||||
-- 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
|
||||
on_attach = function(client, bufnr)
|
||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
|
||||
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,
|
||||
},
|
||||
settings = {
|
||||
kotlin = {
|
||||
linting = { enabled = true },
|
||||
completion = { enabled = true },
|
||||
},
|
||||
},
|
||||
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,
|
||||
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
|
||||
settings = {
|
||||
kotlin = {
|
||||
linting = { enabled = true },
|
||||
completion = { enabled = true },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
-- Setup for Markdown LSP (Marksman)
|
||||
lspconfig.marksman.setup({
|
||||
-- Add additional settings here
|
||||
filetypes = { "markdown", "md" },
|
||||
vim.lsp.config("marksman", {
|
||||
filetypes = { "markdown", "md" },
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
|
||||
lspconfig.pyright.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
-- Custom keymaps and commands for pyright
|
||||
end,
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
vim.lsp.config("pyright", {
|
||||
on_attach = function(client, bufnr)
|
||||
-- Custom keymaps and commands for pyright
|
||||
end,
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,41 +1,44 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
vim.lsp.config("ts_ls", {
|
||||
on_attach = function(client, bufnr)
|
||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
|
||||
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,
|
||||
filetypes = {
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"typescript.tsx",
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"javascript.jsx",
|
||||
},
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
root_dir = lspconfig.util.root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||
settings = {
|
||||
-- Enable document formatting
|
||||
format = {
|
||||
enable = true,
|
||||
insertSpaceAfterCommaDelimiter = true,
|
||||
insertSpaceAfterSemicolon = true,
|
||||
insertSpaceBeforeAndAfterOperator = true,
|
||||
indentStyle = "smart",
|
||||
indentSize = 2,
|
||||
wrapLineLength = 120,
|
||||
},
|
||||
-- Diagnostics and completion settings
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
},
|
||||
completions = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
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,
|
||||
|
||||
filetypes = {
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
},
|
||||
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
|
||||
root_dir = vim.fs.root(0, {
|
||||
"package.json",
|
||||
"tsconfig.json",
|
||||
"jsconfig.json",
|
||||
".git",
|
||||
}),
|
||||
|
||||
settings = {
|
||||
format = {
|
||||
enable = true,
|
||||
insertSpaceAfterCommaDelimiter = true,
|
||||
insertSpaceAfterSemicolon = true,
|
||||
insertSpaceBeforeAndAfterOperator = true,
|
||||
indentStyle = "smart",
|
||||
indentSize = 2,
|
||||
wrapLineLength = 120,
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
},
|
||||
completions = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +1,30 @@
|
|||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"lua",
|
||||
"python",
|
||||
"java",
|
||||
"c",
|
||||
"cpp",
|
||||
"javascript",
|
||||
"kotlin",
|
||||
"go",
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
use_language_tree = true,
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
},
|
||||
autopairs = {
|
||||
enable = true,
|
||||
},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
},
|
||||
-- lua/user/treesitter.lua
|
||||
local ok, configs = pcall(require, "nvim-treesitter.configs")
|
||||
if not ok then
|
||||
vim.notify("nvim-treesitter not found!", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
configs.setup({
|
||||
ensure_installed = {
|
||||
"markdown",
|
||||
"lua",
|
||||
"python",
|
||||
"java",
|
||||
"c",
|
||||
"cpp",
|
||||
"javascript",
|
||||
"kotlin",
|
||||
"go",
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
use_language_tree = true,
|
||||
},
|
||||
incremental_selection = { enable = true },
|
||||
indent = { enable = true },
|
||||
context_commentstring = { enable = true },
|
||||
autopairs = { enable = true },
|
||||
rainbow = { enable = true },
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue