Compare commits

..
22 changed files with 269 additions and 148 deletions

View file

@ -8,5 +8,3 @@ require 'dzu.keymaps'
require 'dzu.plugins' require 'dzu.plugins'
require 'dzu.snippets' require 'dzu.snippets'
require 'dzu.lsp'

View file

@ -1,52 +0,0 @@
local servers = {
"rust_analyzer",
"pyright",
"ts_ls",
"biome",
"clangd",
"lua_ls",
"tinymist",
"jdtls",
"html",
"dockerls",
"nil_ls",
}
local is_ok, handlers = pcall(require, "dzu.lsp.handlers")
if not is_ok then
vim.notify("failed to initialize LSP handlers")
return
end
handlers.setup()
local opts = {
capabilities = handlers.capabilities,
}
for _, server in pairs(servers) do
server = vim.split(server, "@")[1]
local is_ok, conf_opts = pcall(require, "dzu.lsp." .. server)
if not is_ok then
vim.notify("Failed to initialize config for " .. server)
goto continue
end
local opts0 = vim.tbl_deep_extend("force", opts, conf_opts)
vim.lsp.config(server, opts0)
vim.lsp.enable(server, true)
::continue::
end
-- -- format code on save
-- vim.api.nvim_create_autocmd({ "BufWritePre" }, {
-- pattern = {
-- "*.rs", -- rust sources
-- "*.py", -- python sources
-- "*.js", -- javascript sources
-- "*.html", -- html files
-- },
-- callback = function(ev)
-- vim.lsp.buf.format()
-- end,
-- })

View file

@ -1 +0,0 @@
return {}

View file

@ -1,6 +1,6 @@
return { return {
filetypes = { "c", "h", "cpp", "arduino" }, filetypes = { "c", "h", "cpp" },
root_markers = { ".git", "sketch.yaml" }, single_file_support = true,
cmd = { cmd = {
"clangd", "clangd",
-- "-Wall", -- "-Wall",

View file

@ -1 +0,0 @@
return {}

19
nvim/lua/dzu/lsp/init.lua Normal file
View file

@ -0,0 +1,19 @@
-- setup LSPs
local is_ok, _ = pcall(require, "dzu.lsp.mason")
if not is_ok then
vim.notify("failed to setup Mason")
return
end
-- -- format code on save
-- vim.api.nvim_create_autocmd({ "BufWritePre" }, {
-- pattern = {
-- "*.rs", -- rust sources
-- "*.py", -- python sources
-- "*.js", -- javascript sources
-- "*.html", -- html files
-- },
-- callback = function(ev)
-- vim.lsp.buf.format()
-- end,
-- })

View file

@ -1,41 +1,19 @@
local jdk_name = os.getenv("JDTLS_JDK_NAME")
local jdk_path = os.getenv("JDTLS_JDK_PATH")
local classpath = os.getenv("CLASSPATH") or ""
local jdtls_libs = {}
for path in string.gmatch(classpath, "[^:]+") do
if string.len(path) == 0 then
-- empty path, nothing to do
goto continue
end
if string.sub(path, -4) ~= ".jar" then
-- not a jar in path, skip
goto continue
end
table.insert(jdtls_libs, path)
::continue::
end
return { return {
cmd = { "jdtls", "--java-no-verify" },
filetypes = { "java" },
root_markers = { ".git", "build.xml" },
settings = { settings = {
java = { java = {
configuration = { configuration = {
runtimes = { runtimes = {
{ {
name = jdk_name, name = "openjdk 21.0.9",
path = jdk_path, path = "/usr/lib/jvm/java-21-openjdk/",
default = true, default = true,
} }
} }
}, },
project = { project = {
referencedLibraries = jdtls_libs, referencedLibraries = {
'./lib/*.jar',
},
} }
} }
}, },
@ -65,4 +43,5 @@ return {
} }
}, },
init_options = {}, init_options = {},
root_markers = { "build.xml" },
} }

View file

@ -1,7 +1,4 @@
return { return {
cmd = { 'lua-language-server' },
filetypes = { 'lua' },
root_markers = { { '.luarc.json', '.luarc.jsonc' }, '.git' },
settings = { settings = {
Lua = { Lua = {
runtime = { runtime = {

View file

@ -0,0 +1,85 @@
local settings = {
ui = {
border = "none",
icons = {
package_installed = "◍",
package_pending = "◍",
package_uninstalled = "◍",
},
},
log_level = vim.log.levels.INFO,
max_concurrent_installers = 4,
}
require("mason").setup(settings)
local servers = {
{ "rust_analyzer", "rust_analyzer" },
{ "pyright", "pyright" },
{ "ts_ls", nil },
{ "biome", nil },
{ "clangd", "clangd" },
{ "lua_ls", "lua_ls" },
{ "tinymist", "tinymist" },
{ nil, "jdtls" },
{ "html", nil },
{ "dockerls", nil },
}
local ensure_installed = {}
local i = 1
for _, s in pairs(servers) do
local s0 = s[1]
if s0 ~= nil then
table.insert(ensure_installed, i, s0)
i = i + 1
vim.lsp.enable(s0, true)
end
end
for tool, _ in pairs(ADDITIONAL_MASON_TOOLS) do
table.insert(ensure_installed, i, tool)
i = i + 1
end
require("mason-tool-installer").setup({
ensure_installed = ensure_installed,
auto_update = true,
run_on_start = true,
})
require("mason-lspconfig").setup({
automatic_enable = true,
automatic_installation = true,
})
local config_servers = {}
for _, s in pairs(servers) do
local s1 = s[2]
if s1 ~= nil then
table.insert(config_servers, s1)
end
end
local is_ok, handlers = pcall(require, "dzu.lsp.handlers")
if not is_ok then
vim.notify("failed to initialize LSP handlers")
return
end
handlers.setup()
local opts = {
capabilities = handlers.capabilities,
}
for _, server in pairs(config_servers) do
server = vim.split(server, "@")[1]
local is_ok, conf_opts = pcall(require, "dzu.lsp." .. server)
if not is_ok then
vim.notify("Failed to initialize config for " .. server)
goto continue
end
local opts0 = vim.tbl_deep_extend("force", conf_opts, opts)
vim.lsp.config(server, opts0)
vim.lsp.enable(server, true)
::continue::
end

View file

@ -1,5 +0,0 @@
return {
cmd = { "nil" },
root_markers = { { "flake.nix", "flake.lock" }, ".git" },
filetypes = { "nix" },
}

View file

@ -1,7 +1,4 @@
return { return {
cmd = { "pyright-langserver", "--stdio" },
filetypes = { "python" },
root_markers = { ".git" },
settings = { settings = {
pyright = { pyright = {
disableLanguageServices = false, disableLanguageServices = false,

View file

@ -1,7 +1,4 @@
return { return {
cmd = { "rust-analyzer" },
filetypes = { "rust" },
root_markers = { ".git", "Cargo.lock" },
settings = { settings = {
['rust-analyzer'] = { ['rust-analyzer'] = {
diagnostics = { diagnostics = {
@ -22,7 +19,7 @@ return {
enable = true -- show me bounds(?) enable = true -- show me bounds(?)
}, },
termSearch = { termSearch = {
enable = false, -- nested completions? enable = true, -- nested completions?
}, },
}, },
hover = { hover = {

View file

@ -10,9 +10,6 @@ vim.api.nvim_create_user_command("OpenPdf", function()
end, {}) end, {})
return { return {
cmd = { "tinymist" },
filetypes = { "typst" },
root_markers = { ".git", "main.typ" },
settings = { settings = {
formatterMode = "typstyle", formatterMode = "typstyle",
exportPdf = "onType", exportPdf = "onType",

View file

@ -1 +0,0 @@
return {}

View file

@ -58,9 +58,6 @@ local options = {
-- clipboard -- clipboard
clipboard = 'unnamedplus', clipboard = 'unnamedplus',
-- no folding
foldenable = false,
} }
for k, v in pairs(options) do for k, v in pairs(options) do

View file

@ -0,0 +1,11 @@
return {
"mason-org/mason-lspconfig.nvim",
dependencies = {
"mason-org/mason.nvim",
"neovim/nvim-lspconfig",
-- lsp completions
"hrsh7th/cmp-nvim-lsp",
'nvim-java/nvim-java',
},
lazy = false,
}

View file

@ -0,0 +1,29 @@
local function config()
local is_ok, _ = pcall(require, "mason-tool-installer")
if not is_ok then
vim.notify("Failed to setup mason tools")
return
end
local is_ok, _ = pcall(require, "dzu.lsp")
if not is_ok then
vim.notify("failed to setup lsp")
return
end
end
return {
"WhoIsSethDaniel/mason-tool-installer.nvim",
dependencies = {
"mason-org/mason-lspconfig.nvim",
},
config = config,
lazy = false,
opts = {
integrations = {
["mason-lspconfig"] = true,
["mason-null-ls"] = false,
["mason-nvim-dap"] = false,
},
},
}

View file

@ -0,0 +1,4 @@
return {
"mason-org/mason.nvim",
opts = {}
}

View file

@ -203,7 +203,6 @@ end
return { return {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
dependencies = { dependencies = {
"cmp-nvim-lsp",
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",

View file

@ -0,0 +1,56 @@
return {
'nvim-java/nvim-java',
config = function()
require('java').setup({
-- Startup checks
checks = {
nvim_version = true, -- Check Neovim version
nvim_jdtls_conflict = true, -- Check for nvim-jdtls conflict
},
-- JDTLS configuration
jdtls = {
version = '1.54.0',
},
-- Extensions
lombok = {
enable = false,
version = '1.18.40',
},
java_test = {
enable = false,
version = '0.40.1',
},
java_debug_adapter = {
enable = false,
version = '0.58.2',
},
spring_boot_tools = {
enable = false,
version = '1.55.1',
},
-- JDK installation
jdk = {
auto_install = false,
version = '17',
},
-- Logging
log = {
use_console = false,
use_file = true,
level = 'info',
log_file = vim.fn.stdpath('state') .. '/nvim-java.log',
max_lines = 1000,
show_location = false,
},
})
-- vim.lsp.enable('jdtls')
end,
lazy = false,
}

View file

@ -2,7 +2,7 @@
return { return {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
branch = "main", branch = "master",
build = ':TSUpdate', build = ':TSUpdate',
lazy = false, lazy = false,
} }

View file

@ -1,73 +1,89 @@
local M = {} local M = {}
function M.setup() function M.setup()
local is_ok, tree_sitter = pcall(require, "nvim-treesitter") local is_ok, tree_sitter_config = pcall(require, "nvim-treesitter.configs")
if not is_ok then if not is_ok then
vim.notify("couldn't find tree sitter") vim.notify("couldn't find tree sitter")
return return
end end
tree_sitter.setup() local cfg = {
local is_ok, tree_sitter_config = pcall(require, "nvim-treesitter.config")
if not is_ok then
vim.notify("couldn't find tree sitter config")
return
end
local ensure_installed = {
"bash", "bash",
"c", "c",
"comment", { "comment", nil },
"csv", "csv",
"dockerfile", { "dockerfile", nil },
"fish", "fish",
"gitignore", { "gitignore", "gitignore" },
"haskell", { "haskell", "hs" },
"html", "html",
"javascript", { "javascript", "js" },
"typescript", { "typescript", "ts" },
"tsx", "tsx",
"json", "json",
"lua", "lua",
"luadoc", { "luadoc", nil },
"make", { "make", nil },
"markdown", { "markdown", "md" },
"markdown_inline", { "markdown_inline", "md" },
"python", { "python", "py" },
"rust", { "rust", "rs" },
"sql", "sql",
"toml", "toml",
"vim", { "vim", nil },
"vimdoc", { "vimdoc", nil },
"xml", "xml",
"nu", "nu",
"java", "java",
"yaml", "yaml",
"arduino",
} }
local langs = {}
local li = 1
local pattern = {}
local pi = 1
for _, spec in pairs(cfg) do
if type(spec) == "table" then
table.insert(langs, li, spec[1])
li = li + 1
if type(spec[2]) ~= "nil" then
table.insert(pattern, pi, "*." .. spec[2])
pi = pi + 1
end
else
table.insert(langs, li, spec)
li = li + 1
table.insert(pattern, pi, "*." .. spec)
pi = pi + 1
end
end
-- src: https://www.qu8n.com/posts/treesitter-migration-guide-for-nvim-0-12 table.insert(pattern, pi, "Dockerfile*")
local already_installed = require('nvim-treesitter.config').get_installed() pi = pi + 1
local install = vim.iter(ensure_installed) table.insert(pattern, pi, "Cargo.lock")
:filter(function(parser) pi = pi + 1
return not vim.tbl_contains(already_installed, parser) table.insert(pattern, pi, "makefile*")
end) pi = pi + 1
:totable() table.insert(pattern, pi, "Makefile*")
tree_sitter.install(install) pi = pi + 1
vim.treesitter.language.register("xml", "ant") local opts = {
ensure_installed = langs,
highlight = {
enable = true, -- false will disable the whole extension
},
}
tree_sitter_config.setup(opts)
vim.cmd.TSUpdate() vim.cmd.TSUpdate()
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('BufWinEnter', {
pattern = pattern,
callback = function() callback = function()
-- Enable treesitter highlighting and disable regex syntax vim.treesitter.start()
pcall(vim.treesitter.start)
-- Enable treesitter-based indentation
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end, end,
}) })
vim.treesitter.language.register("xml", "ant")
end end
return M return M