update nvim

This commit is contained in:
Kasper Juul Hermansen 2023-02-03 16:08:09 +01:00
parent c5d8b5ef2b
commit 057b357f05
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
19 changed files with 218 additions and 16 deletions

9
lazy.lua Normal file
View File

@ -0,0 +1,9 @@
return {
defaults = { lazy = true },
performance = {
rtp = {
-- customize default disabled vim plugins
disabled_plugins = { "tohtml", "gzip", "matchit", "zipPlugin", "netrwPlugin", "tarPlugin", "matchparen" },
},
},
}

6
lsp/config/denols.lua Normal file
View File

@ -0,0 +1,6 @@
return {
denols = function(opts)
opts.root_dir = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc")
return opts
end,
}

6
lsp/config/eslint.lua Normal file
View File

@ -0,0 +1,6 @@
return {
eslint = function(opts)
opts.root_dir = require("lspconfig.util").root_pattern("package.json", ".eslintrc.json", ".eslintrc.js")
return opts
end,
}

53
lsp/config/jdtls.lua Normal file
View File

@ -0,0 +1,53 @@
return {
jdtls = function(opts)
-- use this function notation to build some variables
local root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }
local root_dir = require("jdtls.setup").find_root(root_markers)
-- calculate workspace dir
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
local workspace_dir = vim.fn.stdpath "data" .. "/site/java/workspace-root/" .. project_name
os.execute("mkdir " .. workspace_dir)
-- get the mason install path
local install_path = require("mason-registry").get_package("jdtls"):get_install_path()
-- get the current OS
local os
print(os)
if vim.fn.has "macunix" then
os = "mac"
elseif vim.fn.has "win32" then
os = "win"
else
os = "linux"
end
-- return the server config
return {
cmd = {
"java",
"-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=ALL",
"-javaagent:" .. install_path .. "/lombok.jar",
"-Xms1g",
"--add-modules=ALL-SYSTEM",
"--add-opens",
"java.base/java.util=ALL-UNNAMED",
"--add-opens",
"java.base/java.lang=ALL-UNNAMED",
"-jar",
vim.fn.glob(install_path .. "/plugins/org.eclipse.equinox.launcher_*.jar"),
"-configuration",
install_path .. "/config_" .. os,
"-data",
workspace_dir,
},
root_dir = root_dir,
}
end,
}

6
lsp/config/tsserver.lua Normal file
View File

@ -0,0 +1,6 @@
return {
tsserver = function(opts)
opts.root_dir = require("lspconfig.util").root_pattern "package.json"
return opts
end,
}

17
lsp/setup_handlers.lua Normal file
View File

@ -0,0 +1,17 @@
return {
-- keys for a specific server name will be used for that LSP
--jdtls = function(server, opts)
-- -- custom sumneko_lua setup handler
-- require("lspconfig")["sumneko_lua"].setup(opts)
--end,
rust_analyzer = function(_, opts) require("rust-tools").setup { server = opts } end,
jdtls = function(_, opts)
vim.api.nvim_create_autocmd("Filetype", {
pattern = "java", -- autocmd to start jdtls
callback = function()
if opts.root_dir and opts.root_dir ~= "" then require("jdtls").start_or_attach(opts) end
end,
})
end,
}

View File

@ -9,6 +9,9 @@ return {
["<leader>bt"] = { "<cmd>BufferLineSortByTabs<cr>", desc = "Sort by tabs" },
-- quick save
-- ["<C-s>"] = { ":w!<cr>", desc = "Save File" }, -- change description but the same command
["<leader>b"] = { name = "Buffer" },
["<leader>P"] = { "<cmd>Telescope projects<cr>", desc = "projects" },
["<leader>."] = { "<cmd>Ranger<cr>", desc = "ranger" },
},
t = {
-- setting a mapping to false will disable it

4
plugins/crates-nvim.lua Normal file
View File

@ -0,0 +1,4 @@
return {
"Saecki/crates.nvim",
config = function() require("crates").setup() end,
}

View File

@ -1,7 +1,7 @@
return {
"williamboman/mason-lspconfig.nvim",
opts = {
ensure_installed = { "sumneko_lua", "rust_analyzer", "gopls", "yamlls", "tsserver", "terraformls" },
automatic_installation = true,
ensure_installed = { "sumneko_lua", "gopls", "yamlls", "tsserver", "terraformls", "jsonls", "jdtls" },
automatic_installation = { exclude = { "rust_analyzer" } },
},
}

View File

@ -1,4 +1,35 @@
return { -- overrides `require("mason-null-ls").setup(...)`
"jay-babu/mason-null-ls.nvim",
opts = { ensure_installed = { "prettier", "stylua" } },
config = function(plugin, opts)
plugin.default_config(opts) -- use the default configuration function
local null_ls = require "null-ls"
require("mason-null-ls").setup_handlers { -- setup custom handlers
prettier = function()
require("null-ls").register(null_ls.builtins.formatting.prettier.with {
condition = function(utils)
return utils.root_has_file "package.json"
or utils.root_has_file ".prettierrc"
or utils.root_has_file ".prettierrc.json"
or utils.root_has_file ".prettierrc.js"
end,
})
end,
-- For prettierd:
-- prettierd = function()
-- require("null-ls").register(require("null-ls").builtins.formatting.prettierd.with({
-- condition = function(utils)
-- return utils.root_has_file("package.json") or utils.root_has_file(".prettierrc") or utils.root_has_file(".prettierrc.json") or utils.root_has_file(".prettierrc.js")
-- end
-- }))
-- end,
-- For eslint_d:
-- eslint_d = function()
-- require("null-ls").register(require("null-ls").builtins.diagnostics.eslint_d.with({
-- condition = function(utils)
-- return utils.root_has_file("package.json") or utils.root_has_file(".eslintrc.json") or utils.root_has_file(".eslintrc.js")
-- end
-- }))
-- end,
}
end,
}

View File

@ -0,0 +1,31 @@
return {
"jay-babu/mason-nvim-dap.nvim",
config = function(self, opts)
self.default_config(opts) -- run default AstroNvim mason-nvim-dap config function
-- do more configuration as needed
local mason_nvim_dap = require "mason-nvim-dap"
mason_nvim_dap.setup_handlers {
python = function(source_name)
local dap = require "dap"
dap.adapters.python = {
type = "executable",
command = "/usr/bin/python3",
args = {
"-m",
"debugpy.adapter",
},
}
dap.configurations.python = {
{
type = "python",
request = "launch",
name = "Launch file",
program = "${file}", -- This configuration will launch the current file if used.
},
}
end,
}
end,
}

24
plugins/nvim-cmp.lua Normal file
View File

@ -0,0 +1,24 @@
return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-emoji", -- add cmp source as dependency of cmp
},
-- override the options table that is used in the `require("cmp").setup()` call
opts = function(_, opts)
-- opts parameter is the default options table
-- the function is lazy loaded so cmp is able to be required
local cmp = require "cmp"
-- modify the sources part of the options table
opts.sources = cmp.config.sources {
{ name = "nvim_lsp", priority = 1000 },
{ name = "luasnip", priority = 750 },
{ name = "buffer", priority = 500 },
{ name = "path", priority = 250 },
{ name = "emoji", priority = 700 }, -- add new source
{ name = "crates", priority = 1000 },
}
-- return the new table to be used
return opts
end,
}

3
plugins/nvim-jdtls.lua Normal file
View File

@ -0,0 +1,3 @@
return {
"mfussenegger/nvim-jdtls", -- load jdtls on module
}

4
plugins/nvim-metals.lua Normal file
View File

@ -0,0 +1,4 @@
return {
"scalameta/nvim-metals",
dependencies = { "nvim-lua/plenary.nvim" },
}

View File

@ -1,5 +1,6 @@
return {
after = "telescope.nvim",
"pwntester/octo.nvim",
event = "UIEnter",
config = function() require("octo").setup() end,
}

View File

@ -1,4 +1,5 @@
return {
"kjuulh/ranger.nvim",
event = "UIEnter",
config = function() require("ranger").setup {} end,
}

3
plugins/rust-tools.lua Normal file
View File

@ -0,0 +1,3 @@
return {
"simrat39/rust-tools.nvim",
}

13
plugins/which-key.lua Normal file
View File

@ -0,0 +1,13 @@
return {
"folke/which-key.nvim",
config = function(plugin, opts)
plugin.default_config(opts)
local wk = require "which-key"
wk.register({
b = { name = "Buffer" },
}, {
mode = "n",
prefix = "<leader>",
})
end,
}

View File

@ -1,13 +0,0 @@
return {
-- first key is the mode, n == normal mode
n = {
-- second key is the prefix, <leader> prefixes
["<leader>"] = {
-- third key is the key to bring up next level and its displayed
-- group name in which-key top level menu
["b"] = { name = "Buffer" },
["P"] = { "<cmd>Telescope projects<cr>", "projects" },
["."] = { "<cmd>Ranger<cr>", "ranger" },
},
},
}