Compare commits
22 changed files with 269 additions and 148 deletions
|
|
@ -8,5 +8,3 @@ require 'dzu.keymaps'
|
|||
require 'dzu.plugins'
|
||||
|
||||
require 'dzu.snippets'
|
||||
|
||||
require 'dzu.lsp'
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
-- })
|
||||
|
|
@ -1 +0,0 @@
|
|||
return {}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
return {
|
||||
filetypes = { "c", "h", "cpp", "arduino" },
|
||||
root_markers = { ".git", "sketch.yaml" },
|
||||
filetypes = { "c", "h", "cpp" },
|
||||
single_file_support = true,
|
||||
cmd = {
|
||||
"clangd",
|
||||
-- "-Wall",
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
return {}
|
||||
19
nvim/lua/dzu/lsp/init.lua
Normal file
19
nvim/lua/dzu/lsp/init.lua
Normal 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,
|
||||
-- })
|
||||
|
|
@ -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 {
|
||||
cmd = { "jdtls", "--java-no-verify" },
|
||||
filetypes = { "java" },
|
||||
root_markers = { ".git", "build.xml" },
|
||||
settings = {
|
||||
java = {
|
||||
configuration = {
|
||||
runtimes = {
|
||||
{
|
||||
name = jdk_name,
|
||||
path = jdk_path,
|
||||
name = "openjdk 21.0.9",
|
||||
path = "/usr/lib/jvm/java-21-openjdk/",
|
||||
default = true,
|
||||
}
|
||||
}
|
||||
},
|
||||
project = {
|
||||
referencedLibraries = jdtls_libs,
|
||||
referencedLibraries = {
|
||||
'./lib/*.jar',
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -65,4 +43,5 @@ return {
|
|||
}
|
||||
},
|
||||
init_options = {},
|
||||
root_markers = { "build.xml" },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
return {
|
||||
cmd = { 'lua-language-server' },
|
||||
filetypes = { 'lua' },
|
||||
root_markers = { { '.luarc.json', '.luarc.jsonc' }, '.git' },
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
|
|
|
|||
85
nvim/lua/dzu/lsp/mason.lua
Normal file
85
nvim/lua/dzu/lsp/mason.lua
Normal 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
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
return {
|
||||
cmd = { "nil" },
|
||||
root_markers = { { "flake.nix", "flake.lock" }, ".git" },
|
||||
filetypes = { "nix" },
|
||||
}
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
return {
|
||||
cmd = { "pyright-langserver", "--stdio" },
|
||||
filetypes = { "python" },
|
||||
root_markers = { ".git" },
|
||||
settings = {
|
||||
pyright = {
|
||||
disableLanguageServices = false,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
return {
|
||||
cmd = { "rust-analyzer" },
|
||||
filetypes = { "rust" },
|
||||
root_markers = { ".git", "Cargo.lock" },
|
||||
settings = {
|
||||
['rust-analyzer'] = {
|
||||
diagnostics = {
|
||||
|
|
@ -22,7 +19,7 @@ return {
|
|||
enable = true -- show me bounds(?)
|
||||
},
|
||||
termSearch = {
|
||||
enable = false, -- nested completions?
|
||||
enable = true, -- nested completions?
|
||||
},
|
||||
},
|
||||
hover = {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,6 @@ vim.api.nvim_create_user_command("OpenPdf", function()
|
|||
end, {})
|
||||
|
||||
return {
|
||||
cmd = { "tinymist" },
|
||||
filetypes = { "typst" },
|
||||
root_markers = { ".git", "main.typ" },
|
||||
settings = {
|
||||
formatterMode = "typstyle",
|
||||
exportPdf = "onType",
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
return {}
|
||||
|
|
@ -58,9 +58,6 @@ local options = {
|
|||
|
||||
-- clipboard
|
||||
clipboard = 'unnamedplus',
|
||||
|
||||
-- no folding
|
||||
foldenable = false,
|
||||
}
|
||||
|
||||
for k, v in pairs(options) do
|
||||
|
|
|
|||
11
nvim/lua/dzu/plugins/lsp.lua
Normal file
11
nvim/lua/dzu/plugins/lsp.lua
Normal 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,
|
||||
}
|
||||
29
nvim/lua/dzu/plugins/mason-tools.lua
Normal file
29
nvim/lua/dzu/plugins/mason-tools.lua
Normal 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,
|
||||
},
|
||||
},
|
||||
}
|
||||
4
nvim/lua/dzu/plugins/mason.lua
Normal file
4
nvim/lua/dzu/plugins/mason.lua
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
return {
|
||||
"mason-org/mason.nvim",
|
||||
opts = {}
|
||||
}
|
||||
|
|
@ -203,7 +203,6 @@ end
|
|||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"cmp-nvim-lsp",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
|
|
|
|||
56
nvim/lua/dzu/plugins/nvim-java.lua
Normal file
56
nvim/lua/dzu/plugins/nvim-java.lua
Normal 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,
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = "main",
|
||||
branch = "master",
|
||||
build = ':TSUpdate',
|
||||
lazy = false,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,73 +1,89 @@
|
|||
local M = {}
|
||||
|
||||
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
|
||||
vim.notify("couldn't find tree sitter")
|
||||
return
|
||||
end
|
||||
|
||||
tree_sitter.setup()
|
||||
|
||||
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 = {
|
||||
local cfg = {
|
||||
"bash",
|
||||
"c",
|
||||
"comment",
|
||||
{ "comment", nil },
|
||||
"csv",
|
||||
"dockerfile",
|
||||
{ "dockerfile", nil },
|
||||
"fish",
|
||||
"gitignore",
|
||||
"haskell",
|
||||
{ "gitignore", "gitignore" },
|
||||
{ "haskell", "hs" },
|
||||
"html",
|
||||
"javascript",
|
||||
"typescript",
|
||||
{ "javascript", "js" },
|
||||
{ "typescript", "ts" },
|
||||
"tsx",
|
||||
"json",
|
||||
"lua",
|
||||
"luadoc",
|
||||
"make",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"python",
|
||||
"rust",
|
||||
{ "luadoc", nil },
|
||||
{ "make", nil },
|
||||
{ "markdown", "md" },
|
||||
{ "markdown_inline", "md" },
|
||||
{ "python", "py" },
|
||||
{ "rust", "rs" },
|
||||
"sql",
|
||||
"toml",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
{ "vim", nil },
|
||||
{ "vimdoc", nil },
|
||||
"xml",
|
||||
"nu",
|
||||
"java",
|
||||
"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
|
||||
local already_installed = require('nvim-treesitter.config').get_installed()
|
||||
local install = vim.iter(ensure_installed)
|
||||
:filter(function(parser)
|
||||
return not vim.tbl_contains(already_installed, parser)
|
||||
end)
|
||||
:totable()
|
||||
tree_sitter.install(install)
|
||||
table.insert(pattern, pi, "Dockerfile*")
|
||||
pi = pi + 1
|
||||
table.insert(pattern, pi, "Cargo.lock")
|
||||
pi = pi + 1
|
||||
table.insert(pattern, pi, "makefile*")
|
||||
pi = pi + 1
|
||||
table.insert(pattern, pi, "Makefile*")
|
||||
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.api.nvim_create_autocmd('FileType', {
|
||||
vim.api.nvim_create_autocmd('BufWinEnter', {
|
||||
pattern = pattern,
|
||||
callback = function()
|
||||
-- Enable treesitter highlighting and disable regex syntax
|
||||
pcall(vim.treesitter.start)
|
||||
-- Enable treesitter-based indentation
|
||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
vim.treesitter.start()
|
||||
end,
|
||||
})
|
||||
|
||||
vim.treesitter.language.register("xml", "ant")
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Reference in a new issue