update
This commit is contained in:
parent
e2eb892edb
commit
ee6974510f
18 changed files with 129 additions and 42 deletions
48
init.lua
48
init.lua
|
|
@ -1,12 +1,27 @@
|
||||||
|
-- Bootstrap packer.nvim if not already installed
|
||||||
|
local ensure_packer = function()
|
||||||
|
local fn = vim.fn
|
||||||
|
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
||||||
|
if fn.empty(fn.glob(install_path)) > 0 then
|
||||||
|
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
|
||||||
|
vim.cmd([[packadd packer.nvim]])
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local packer_bootstrap = ensure_packer()
|
||||||
|
|
||||||
-- Load user configuration files
|
-- Load user configuration files
|
||||||
require("user.options")
|
require("user.options")
|
||||||
require("user.keymaps")
|
require("user.keymaps")
|
||||||
require("user.cmp")
|
require("user.cmp")
|
||||||
require("user.java")
|
|
||||||
require("user.autopairs")
|
require("user.autopairs")
|
||||||
require("user.telescope")
|
require("user.telescope")
|
||||||
require("user.gruvbox")
|
require("user.gruvbox")
|
||||||
require("user.lsp")
|
require("user.lsp")
|
||||||
|
require("user.typescript-tools")
|
||||||
|
require("user.null-ls")
|
||||||
require("user.treesitter")
|
require("user.treesitter")
|
||||||
require("user.terminal")
|
require("user.terminal")
|
||||||
require("user.markdown")
|
require("user.markdown")
|
||||||
|
|
@ -37,11 +52,14 @@ return require("packer").startup(function(use)
|
||||||
-- NERDTree plugin
|
-- NERDTree plugin
|
||||||
use("preservim/nerdtree")
|
use("preservim/nerdtree")
|
||||||
|
|
||||||
-- Plugin for integrating formatters/linters
|
-- Plugin for integrating formatters/linters (community fork of archived null-ls)
|
||||||
use("jose-elias-alvarez/null-ls.nvim")
|
use("nvimtools/none-ls.nvim")
|
||||||
|
|
||||||
-- -- TS Server
|
-- Modern TypeScript integration (replaces archived nvim-lsp-ts-utils)
|
||||||
use("jose-elias-alvarez/nvim-lsp-ts-utils")
|
use({
|
||||||
|
"pmizio/typescript-tools.nvim",
|
||||||
|
requires = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
||||||
|
})
|
||||||
|
|
||||||
-- Treesitter
|
-- Treesitter
|
||||||
use("nvim-treesitter/nvim-treesitter")
|
use("nvim-treesitter/nvim-treesitter")
|
||||||
|
|
@ -96,18 +114,10 @@ return require("packer").startup(function(use)
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Mason LSPConfig for integrating Mason with nvim-lspconfig
|
-- Mason LSPConfig for integrating Mason with nvim-lspconfig
|
||||||
use({
|
use("williamboman/mason-lspconfig.nvim")
|
||||||
"williamboman/mason-lspconfig.nvim",
|
|
||||||
config = function()
|
-- Automatically install plugins on first run
|
||||||
require("mason-lspconfig").setup({
|
if packer_bootstrap then
|
||||||
ensure_installed = {
|
require("packer").sync()
|
||||||
"pyright",
|
end
|
||||||
"ts_ls",
|
|
||||||
"jdtls",
|
|
||||||
"marksman",
|
|
||||||
"kotlin_language_server",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
-- lua/user/autopairs.lua
|
-- lua/user/autopairs.lua
|
||||||
require('nvim-autopairs').setup{
|
local status_ok, autopairs = pcall(require, 'nvim-autopairs')
|
||||||
|
if not status_ok then
|
||||||
|
vim.notify("nvim-autopairs not found — run :PackerSync", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
autopairs.setup{
|
||||||
disable_filetype = { "TelescopePrompt", "vim" },
|
disable_filetype = { "TelescopePrompt", "vim" },
|
||||||
check_ts = true, -- Enable Treesitter integration
|
check_ts = true, -- Enable Treesitter integration
|
||||||
ts_config = {
|
ts_config = {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
-- ~/.config/nvim/lua/user/cmp.lua
|
-- ~/.config/nvim/lua/user/cmp.lua
|
||||||
|
|
||||||
local cmp = require("cmp")
|
local status_ok, cmp = pcall(require, "cmp")
|
||||||
|
if not status_ok then
|
||||||
|
vim.notify("nvim-cmp not found — run :PackerSync", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
-- Throttle LSP completion requests.
|
-- Throttle LSP completion requests.
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,11 @@ function M.create_file(filename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.prompt_create_file()
|
||||||
|
local filename = vim.fn.input("Filename: ")
|
||||||
|
if filename and filename ~= "" then
|
||||||
|
M.create_file(filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
-- Default options:
|
-- Default options:
|
||||||
require("gruvbox").setup({
|
local status_ok, gruvbox = pcall(require, "gruvbox")
|
||||||
|
if not status_ok then
|
||||||
|
vim.notify("gruvbox.nvim not found — run :PackerSync", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
gruvbox.setup({
|
||||||
terminal_colors = true, -- add neovim terminal colors
|
terminal_colors = true, -- add neovim terminal colors
|
||||||
undercurl = true,
|
undercurl = true,
|
||||||
underline = true,
|
underline = true,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
local jdtls = require('jdtls')
|
local status_ok, jdtls = pcall(require, 'jdtls')
|
||||||
|
if not status_ok then
|
||||||
|
vim.notify("nvim-jdtls not found — run :PackerSync", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
pattern = "java",
|
pattern = "java",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ local search_replace = require("user.search_replace")
|
||||||
vim.g.mapleader = " " -- Set Space as leader key
|
vim.g.mapleader = " " -- Set Space as leader key
|
||||||
|
|
||||||
-- Keybinding to format the current buffer
|
-- Keybinding to format the current buffer
|
||||||
vim.api.nvim_set_keymap('n', '<leader>f', ':lua vim.lsp.buf.format({ async = true })<CR>', { noremap = true, silent = true })
|
vim.api.nvim_set_keymap('n', '<leader>f', ':lua vim.lsp.buf.format()<CR>', { noremap = true, silent = true })
|
||||||
|
|
||||||
-- Save file
|
-- Save file
|
||||||
map("n", "<leader>w", ":w<CR>", default_opts)
|
map("n", "<leader>w", ":w<CR>", default_opts)
|
||||||
|
|
@ -97,8 +97,8 @@ map("n", "<leader>mf", ":MarkdownPreviewFollow<CR>", { noremap = true, silent =
|
||||||
-- Optional: Key binding to toggle Markdown preview
|
-- Optional: Key binding to toggle Markdown preview
|
||||||
map("n", "<leader>mt", ":call ToggleMarkdownPreview()<CR>", { noremap = true, silent = true })
|
map("n", "<leader>mt", ":call ToggleMarkdownPreview()<CR>", { noremap = true, silent = true })
|
||||||
|
|
||||||
-- java at key binding
|
-- Java: organize imports
|
||||||
map("n", "<leader>jf", ":lua vim.lsp.buf.at()<CR>", { noremap = true, silent = true })
|
map("n", "<leader>jo", ":lua vim.lsp.buf.code_action({ context = { only = { 'source.organizeImports' } }, apply = true })<CR>", { noremap = true, silent = true })
|
||||||
|
|
||||||
-- search and replace function
|
-- search and replace function
|
||||||
map("n", "<leader>sr", ':lua require("user.search_replace").search_replace()<CR>', { noremap = true, silent = true })
|
map("n", "<leader>sr", ':lua require("user.search_replace").search_replace()<CR>', { noremap = true, silent = true })
|
||||||
|
|
@ -106,11 +106,11 @@ map("n", "<leader>sr", ':lua require("user.search_replace").search_replace()<CR>
|
||||||
-- Key mapping to trigger LSP rename
|
-- Key mapping to trigger LSP rename
|
||||||
vim.api.nvim_set_keymap("n", "<leader>rn", ":lua vim.lsp.buf.rename()<CR>", { noremap = true, silent = true })
|
vim.api.nvim_set_keymap("n", "<leader>rn", ":lua vim.lsp.buf.rename()<CR>", { noremap = true, silent = true })
|
||||||
|
|
||||||
-- In init.lua or lua/user/keymaps.lua
|
-- Create a new file (prompts for filename)
|
||||||
vim.api.nvim_set_keymap(
|
vim.api.nvim_set_keymap(
|
||||||
"n",
|
"n",
|
||||||
"<Leader>cf",
|
"<Leader>cf",
|
||||||
":lua require('user.files_utils').create_file('NewFile.java')<CR>",
|
":lua require('user.files_utils').prompt_create_file()<CR>",
|
||||||
{ noremap = true, silent = true }
|
{ noremap = true, silent = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
-- These files should now use vim.lsp.config and vim.lsp.enable
|
-- These files should now use vim.lsp.config and vim.lsp.enable
|
||||||
require("user.lsp_servers.pyright")
|
require("user.lsp_servers.pyright")
|
||||||
require("user.lsp_servers.ts_ls")
|
require("user.lsp_servers.ts_ls")
|
||||||
-- require("user.lsp_servers.jdtls")
|
require("user.lsp_servers.jdtls")
|
||||||
require("user.lsp_servers.marksman")
|
require("user.lsp_servers.marksman")
|
||||||
require("user.lsp_servers.kotlin_ls")
|
require("user.lsp_servers.kotlin_ls")
|
||||||
require("user.lsp_servers.dartls")
|
require("user.lsp_servers.dartls")
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
-- Go LSP configuration
|
-- Go LSP configuration
|
||||||
-- Uses gopls installed via Mason
|
-- Uses gopls installed via Mason
|
||||||
|
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
|
local capabilities = status_ok
|
||||||
|
and cmp_nvim_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
or vim.lsp.protocol.make_client_capabilities()
|
||||||
|
|
||||||
vim.lsp.config("gopls", {
|
vim.lsp.config("gopls", {
|
||||||
cmd = { "gopls" },
|
cmd = { "gopls" },
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
-- 1. Setup paths and capabilities
|
-- 1. Setup paths and capabilities
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
local java_bin = "/usr/lib/jvm/java-21-openjdk-amd64/bin/java"
|
local capabilities = status_ok
|
||||||
|
and cmp_nvim_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
or vim.lsp.protocol.make_client_capabilities()
|
||||||
|
local java_bin = "java" -- use java from PATH
|
||||||
local jdtls_path = vim.fn.stdpath("data") .. "/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 jdtls_launcher_jar = vim.fn.glob(jdtls_path .. "/plugins/org.eclipse.equinox.launcher_*.jar")
|
||||||
local lombok_jar = jdtls_path .. "/lombok.jar"
|
local lombok_jar = jdtls_path .. "/lombok.jar"
|
||||||
|
|
@ -56,9 +59,6 @@ vim.lsp.config('jdtls', {
|
||||||
},
|
},
|
||||||
format = {
|
format = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
settings = {
|
|
||||||
url = jdtls_path .. "/eclipse-formatter.xml",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ if vim.fn.executable(bin) == 0 then
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Build capabilities, then strip formatting to prevent ktfmt OOMs.
|
-- Build capabilities, then strip formatting to prevent ktfmt OOMs.
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
|
local capabilities = status_ok and cmp_nvim_lsp.default_capabilities() or vim.lsp.protocol.make_client_capabilities()
|
||||||
capabilities.textDocument.formatting = nil
|
capabilities.textDocument.formatting = nil
|
||||||
capabilities.textDocument.rangeFormatting = nil
|
capabilities.textDocument.rangeFormatting = nil
|
||||||
capabilities.textDocument.onTypeFormatting = nil
|
capabilities.textDocument.onTypeFormatting = nil
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
-- Svelte LSP configuration
|
-- Svelte LSP configuration
|
||||||
-- Uses svelte-language-server installed via Mason
|
-- Uses svelte-language-server installed via Mason
|
||||||
|
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
|
local capabilities = status_ok
|
||||||
|
and cmp_nvim_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
or vim.lsp.protocol.make_client_capabilities()
|
||||||
|
|
||||||
vim.lsp.config("svelte", {
|
vim.lsp.config("svelte", {
|
||||||
cmd = { "svelteserver", "--stdio" },
|
cmd = { "svelteserver", "--stdio" },
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
-- TypeScript/JavaScript LSP configuration
|
-- TypeScript/JavaScript LSP configuration
|
||||||
-- Uses typescript-language-server installed via Mason
|
-- Uses typescript-language-server installed via Mason
|
||||||
|
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
|
local capabilities = status_ok
|
||||||
|
and cmp_nvim_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
or vim.lsp.protocol.make_client_capabilities()
|
||||||
|
|
||||||
vim.lsp.config("ts_ls", {
|
vim.lsp.config("ts_ls", {
|
||||||
cmd = { "typescript-language-server", "--stdio" },
|
cmd = { "typescript-language-server", "--stdio" },
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
-- File: lua/user/null-ls.lua
|
-- File: lua/user/null-ls.lua
|
||||||
|
|
||||||
local null_ls = require("null-ls")
|
local status_ok, null_ls = pcall(require, "null-ls")
|
||||||
|
if not status_ok then
|
||||||
|
vim.notify("null-ls.nvim not found — run :PackerSync", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- Define builtins for formatting
|
-- Define builtins for formatting
|
||||||
local formatting = null_ls.builtins.formatting
|
local formatting = null_ls.builtins.formatting
|
||||||
|
|
@ -47,7 +51,7 @@ null_ls.setup({
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
local view = vim.fn.winsaveview()
|
local view = vim.fn.winsaveview()
|
||||||
vim.lsp.buf.format({ async = true })
|
vim.lsp.buf.format()
|
||||||
vim.fn.winrestview(view)
|
vim.fn.winrestview(view)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
local opt = vim.opt
|
local opt = vim.opt
|
||||||
|
|
||||||
|
-- Suppress vim.tbl_islist deprecation (from packer.nvim / older plugins on Neovim 0.10+)
|
||||||
|
vim.deprecated = vim.deprecated or {}
|
||||||
|
vim.deprecated.tbl_islist = false
|
||||||
|
|
||||||
-- Line numbers
|
-- Line numbers
|
||||||
opt.number = true
|
opt.number = true
|
||||||
opt.relativenumber = true
|
opt.relativenumber = true
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
-- lua/user/telescope.lua
|
-- lua/user/telescope.lua
|
||||||
|
|
||||||
local telescope = require('telescope')
|
local status_ok, telescope = pcall(require, 'telescope')
|
||||||
|
if not status_ok then
|
||||||
|
vim.notify("telescope.nvim not found — run :PackerSync", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
local actions = require('telescope.actions')
|
local actions = require('telescope.actions')
|
||||||
|
|
||||||
telescope.setup{
|
telescope.setup{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
require("nvim-treesitter").setup({
|
local status_ok, ts = pcall(require, "nvim-treesitter")
|
||||||
|
if not status_ok then
|
||||||
|
vim.notify("nvim-treesitter not found — run :PackerSync", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ts.setup({
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
"markdown",
|
"markdown",
|
||||||
"markdown_inline",
|
"markdown_inline",
|
||||||
|
|
|
||||||
25
lua/user/typescript-tools.lua
Normal file
25
lua/user/typescript-tools.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
-- TypeScript tools configuration (replaces nvim-lsp-ts-utils)
|
||||||
|
|
||||||
|
local status_ok, ts_tools = pcall(require, "typescript-tools")
|
||||||
|
if not status_ok then
|
||||||
|
vim.notify("typescript-tools.nvim not found — run :PackerSync", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
ts_tools.setup({
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
-- Disable formatting via tsserver, use none-ls instead
|
||||||
|
client.server_capabilities.documentFormattingProvider = false
|
||||||
|
client.server_capabilities.documentRangeFormattingProvider = false
|
||||||
|
end,
|
||||||
|
settings = {
|
||||||
|
-- Import on completion
|
||||||
|
complete_function_calls = true,
|
||||||
|
-- Include "this" in auto-imports
|
||||||
|
include_completions_with_insert_text = true,
|
||||||
|
-- Enable/disable spawning of tsserver instances
|
||||||
|
separate_diagnostic_server = true,
|
||||||
|
-- Path to tsserver (auto-detected from Mason if not set)
|
||||||
|
tsserver_path = nil,
|
||||||
|
},
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue