kitchen sink now don't support any version lower than 0.11.0 for lsp
- dap now works for java and c
This commit is contained in:
158
after/ftplugin/java.lua
Normal file
158
after/ftplugin/java.lua
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
local misc = require("core.misc")
|
||||||
|
local map, auto = misc.map, misc.auto
|
||||||
|
|
||||||
|
local jdtls = require("jdtls")
|
||||||
|
local jdtls_install = vim.fs.joinpath(vim.fn.stdpath('data'),
|
||||||
|
"/mason/packages/jdtls")
|
||||||
|
local java_dap_install = vim.fs.joinpath(vim.fn.stdpath('data'),
|
||||||
|
"/mason/packages/java-debug-adapter")
|
||||||
|
|
||||||
|
-- make sure to check if things with 💀 need updating
|
||||||
|
local config = {
|
||||||
|
cmd = {
|
||||||
|
"/usr/lib/jvm/openjdk21/bin/java", -- 💀
|
||||||
|
"-jar", vim.fn.glob(jdtls_install.."/plugins/org.eclipse.equinox.launcher_*.jar"), -- 💀
|
||||||
|
"-configuration", jdtls_install.."/config_linux",
|
||||||
|
"-data", vim.fn.stdpath("cache").."/nvim-jdtls",
|
||||||
|
|
||||||
|
"--add-modules=ALL-SYSTEM",
|
||||||
|
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
|
||||||
|
"--add-opens", "java.base/java.util=ALL-UNNAMED",
|
||||||
|
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
||||||
|
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
||||||
|
"-Dlog.level=ALL",
|
||||||
|
"-Dlog.protocol=true",
|
||||||
|
"-Dosgi.bundles.defaultStartLevel=4",
|
||||||
|
"-Xmx1G",
|
||||||
|
},
|
||||||
|
|
||||||
|
root_dir = vim.fs.dirname(vim.fs.find({
|
||||||
|
"gradlew",
|
||||||
|
".git",
|
||||||
|
"mvnw",
|
||||||
|
"settings.gradle", -- Gradle (multi-project)
|
||||||
|
"settings.gradle.kts", -- Gradle (multi-project)
|
||||||
|
"build.xml", -- Ant
|
||||||
|
"pom.xml" -- Maven
|
||||||
|
}, { upward = true })[1]),
|
||||||
|
|
||||||
|
on_attach = function(_, bufnr)
|
||||||
|
jdtls.setup.add_commands()
|
||||||
|
|
||||||
|
-- add some jdtls specific mappings
|
||||||
|
local opts = { buffer = bufnr }
|
||||||
|
map("n", "cri", jdtls.organize_imports, opts)
|
||||||
|
map("n", "crv", jdtls.extract_variable, opts)
|
||||||
|
map("n", "crc", jdtls.extract_constant, opts)
|
||||||
|
map("x", "crv", function() jdtls.extract_variable(true) end, opts)
|
||||||
|
map("x", "crc", function() jdtls.extract_constant(true) end, opts)
|
||||||
|
map("x", "crm", function() jdtls.extract_method(true) end, opts)
|
||||||
|
|
||||||
|
pcall(vim.lsp.codelens.refresh)
|
||||||
|
auto("BufWritePost", {
|
||||||
|
buffer = bufnr,
|
||||||
|
desc = "refresh codelens",
|
||||||
|
callback = function()
|
||||||
|
pcall(vim.lsp.codelens.refresh)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- setup nvim-dap
|
||||||
|
require("dap").adapters.java = nil -- remove any old java adapters
|
||||||
|
jdtls.setup_dap({ hotcodereplace = "auto" })
|
||||||
|
require("jdtls.dap").setup_dap_main_class_configs()
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- don"t print out status messages
|
||||||
|
handlers = {
|
||||||
|
["language/status"] = function() end
|
||||||
|
},
|
||||||
|
|
||||||
|
init_options = {
|
||||||
|
bundles = {
|
||||||
|
vim.fs.joinpath(java_dap_install,
|
||||||
|
vim.fn.glob("/extension/server/com.microsoft.java.debug.plugin-*.jar",
|
||||||
|
true)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- generate the path to the java file(s)
|
||||||
|
---@type string|nil
|
||||||
|
local cache_path = vim.fs.joinpath(vim.fn.stdpath("cache"), "/JavaVersion.class")
|
||||||
|
---@type string|nil
|
||||||
|
local src_path = vim.fs.joinpath(vim.fn.stdpath("config"), "/extras/JavaVersion.java")
|
||||||
|
|
||||||
|
-- if either path is invalid
|
||||||
|
if not cache_path or not src_path then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
--- build a cache of the JavaVersion code
|
||||||
|
local function build_cache()
|
||||||
|
-- check if we have javac
|
||||||
|
vim.system({ "javac" }, {}, function(out)
|
||||||
|
if out.code == 127 then
|
||||||
|
cache_path = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- compile our code
|
||||||
|
vim.system({ "javac", src_path, "-d", vim.fn.stdpath("cache") }, {}, function(out)
|
||||||
|
if out.code ~= 0 then
|
||||||
|
cache_path = nil
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- check if we have a compiled version of JavaVersion
|
||||||
|
local f, _ = io.open(cache_path, "r")
|
||||||
|
if not f then -- if we don"t have a cache
|
||||||
|
build_cache()
|
||||||
|
else
|
||||||
|
io.close(f)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function version_check()
|
||||||
|
-- check the java version
|
||||||
|
local out = vim.system({
|
||||||
|
config.cmd[1], -- use the same java executable that the lsp will be using
|
||||||
|
(cache_path and "JavaVersion") or src_path
|
||||||
|
}, { cwd = vim.fn.stdpath("cache"), text = true }):wait()
|
||||||
|
|
||||||
|
-- parse the version information aquired
|
||||||
|
local v = vim.version.parse(out.stdout)
|
||||||
|
|
||||||
|
-- if there's an error, no version info, or the java version is
|
||||||
|
-- less than 21 stop the lsp from starting
|
||||||
|
if out.code ~= 0 then
|
||||||
|
vim.notify(string.format(
|
||||||
|
"java version check failed: exit code %s", out.code),
|
||||||
|
vim.log.levels.ERROR, { title = misc.appid })
|
||||||
|
vim.notify(string.format(
|
||||||
|
"%s", vim.inspect(out.stdout)),
|
||||||
|
vim.log.levels.ERROR, { title = misc.appid })
|
||||||
|
return false
|
||||||
|
elseif not v then
|
||||||
|
vim.notify("no java version info found", vim.log.levels.ERROR,
|
||||||
|
{ title = misc.appid })
|
||||||
|
return false
|
||||||
|
elseif v.major < 21 then
|
||||||
|
vim.notify(string.format(
|
||||||
|
"java version %s < 21.0.0 Cannot run jdtls, bailing out",
|
||||||
|
v[1] .. "." .. v[2] .. "." .. v[3]),
|
||||||
|
vim.log.levels.ERROR, { title = misc.appid })
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- start the jdtls with dap!
|
||||||
|
if not version_check() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
jdtls.start_or_attach(config)
|
@ -1,28 +0,0 @@
|
|||||||
local misc = require('core.misc')
|
|
||||||
|
|
||||||
-- make sure norg parsers are installed before opening a norg file, currently
|
|
||||||
-- there are two parsers: norg, and norg_meta
|
|
||||||
local found = {}
|
|
||||||
found[0] = 0 -- used to store the number of elements in the table
|
|
||||||
|
|
||||||
-- check for the parsers
|
|
||||||
misc.loopf(vim.fn.stdpath("data").."/site/pack/deps/opt/nvim-treesitter/parser",
|
|
||||||
function(file)
|
|
||||||
if string.find(file, "norg") then
|
|
||||||
found[file] = true
|
|
||||||
found[0] = found[0] + 1
|
|
||||||
end
|
|
||||||
end, "so")
|
|
||||||
|
|
||||||
-- if the parsers don't exist download them
|
|
||||||
if found[0] < 2 and
|
|
||||||
(not found["norg.so"] or not found["norg_meta.so"]) then
|
|
||||||
vim.cmd("Neorg sync-parsers")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set colorcolumn in norg buffers
|
|
||||||
vim.opt_local.colorcolumn = { 80 }
|
|
||||||
|
|
||||||
-- make text wrap at the colorcolumn automatically
|
|
||||||
vim.api.nvim_set_option_value("textwidth",
|
|
||||||
tonumber(vim.api.nvim_get_option_value("colorcolumn", {})), { buf = 0 })
|
|
9
after/lsp/basedpyright.lua
Normal file
9
after/lsp/basedpyright.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
local map = require("core.misc").map
|
||||||
|
|
||||||
|
return {
|
||||||
|
on_attach = function(_, bufnr)
|
||||||
|
-- add some basedpyright specific mappings
|
||||||
|
local opts = { buffer = bufnr }
|
||||||
|
map("n", "cri", "<cmd>PyrightOrganizeImports<CR>", opts)
|
||||||
|
end,
|
||||||
|
}
|
27
after/lsp/clangd.lua
Normal file
27
after/lsp/clangd.lua
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
local map = require("core.misc").map
|
||||||
|
|
||||||
|
return {
|
||||||
|
on_attach = function(_, bufnr)
|
||||||
|
-- add some clangd specific mappings
|
||||||
|
local opts = { buffer = bufnr }
|
||||||
|
map("n", "<leader>o", "<cmd>ClangdSwitchSourceHeader<CR>", opts)
|
||||||
|
end,
|
||||||
|
|
||||||
|
cmd = {
|
||||||
|
"clangd",
|
||||||
|
"--background-index",
|
||||||
|
"--clang-tidy",
|
||||||
|
"--header-insertion=iwyu",
|
||||||
|
"--completion-style=detailed",
|
||||||
|
"--function-arg-placeholders",
|
||||||
|
"--fallback-style=llvm"
|
||||||
|
},
|
||||||
|
|
||||||
|
init_options = {
|
||||||
|
usePlaceholders = true,
|
||||||
|
clangdFileStatus = true,
|
||||||
|
fallback_flags = {
|
||||||
|
"-xc" -- makes clangd think we"re using c instead of c++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
after/lsp/lua_ls.lua
Normal file
24
after/lsp/lua_ls.lua
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
return {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim", "mp" }
|
||||||
|
},
|
||||||
|
runtime = {
|
||||||
|
version = "LuaJIT"
|
||||||
|
},
|
||||||
|
format = {
|
||||||
|
enable = false
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
checkThirdParty = true,
|
||||||
|
library = {
|
||||||
|
vim.env.VIMRUNTIME
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
root_markers = { ".luarc.json", ".luarc.jsonc", ".luacheckrc", ".stylua.toml",
|
||||||
|
"stylua.toml", "selene.toml", "selene.yml", "README.md" }
|
||||||
|
}
|
@ -102,14 +102,16 @@ auto("FileType", {
|
|||||||
|
|
||||||
-- lsp folding: vim.o.foldexpr = "v:lua.vim.lsp.foldexpr()"
|
-- lsp folding: vim.o.foldexpr = "v:lua.vim.lsp.foldexpr()"
|
||||||
-- waiting on https://github.com/neovim/neovim/pull/31311 to hit a release
|
-- waiting on https://github.com/neovim/neovim/pull/31311 to hit a release
|
||||||
require("core.lsp.functions").add_capabilities({
|
vim.lsp.config['*'] = {
|
||||||
textDocument = {
|
capabilities = {
|
||||||
foldingRange = {
|
textDocument = {
|
||||||
dynamicRegistration = false,
|
foldingRange = {
|
||||||
lineFoldingOnly = true
|
dynamicRegistration = false,
|
||||||
|
lineFoldingOnly = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
vim.opt.foldlevelstart = 99
|
vim.opt.foldlevelstart = 99
|
||||||
vim.opt.foldlevel = 99
|
vim.opt.foldlevel = 99
|
||||||
|
125
lua/conf/plugins/blink.lua
Normal file
125
lua/conf/plugins/blink.lua
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
return { "Saghen/blink.cmp",
|
||||||
|
branch = "v1.2.0",
|
||||||
|
requires = {
|
||||||
|
"xzbdmw/colorful-menu.nvim",
|
||||||
|
"L3MON4D3/LuaSnip"
|
||||||
|
},
|
||||||
|
function()
|
||||||
|
local colormenu = require("colorful-menu")
|
||||||
|
require("blink.cmp").setup {
|
||||||
|
keymap = {
|
||||||
|
preset = "none", -- I don't like the default documentation scroll binds
|
||||||
|
["<C-y>"] = { "select_and_accept" },
|
||||||
|
["<C-n>"] = { "select_next", "fallback_to_mappings" },
|
||||||
|
["<C-p>"] = { "select_prev", "fallback_to_mappings" },
|
||||||
|
|
||||||
|
["<C-u>"] = { "scroll_documentation_up", "fallback" },
|
||||||
|
["<C-d>"] = { "scroll_documentation_down", "fallback" }
|
||||||
|
},
|
||||||
|
|
||||||
|
completion = {
|
||||||
|
menu = {
|
||||||
|
scrollbar = false,
|
||||||
|
border = vim.g.border_style,
|
||||||
|
draw = {
|
||||||
|
columns = {
|
||||||
|
{ "kind_icon" },
|
||||||
|
{ "label", "label_description", gap = 1 },
|
||||||
|
{ "kind" }
|
||||||
|
},
|
||||||
|
|
||||||
|
-- blink.cmp should not take this much damn work to make it look
|
||||||
|
-- semi-decent
|
||||||
|
components = {
|
||||||
|
-- we replace the kind icon with the an icon for the source
|
||||||
|
kind_icon = {
|
||||||
|
text = function(ctx)
|
||||||
|
local menu_icon = {
|
||||||
|
"?", -- fallback
|
||||||
|
lsp = "λ",
|
||||||
|
snippets = "%",
|
||||||
|
buffer = "@",
|
||||||
|
path = "#",
|
||||||
|
cmdline = "$"
|
||||||
|
}
|
||||||
|
|
||||||
|
local icon = menu_icon[ctx.source_id]
|
||||||
|
if icon == nil then
|
||||||
|
icon = menu_icon[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
return icon
|
||||||
|
end,
|
||||||
|
highlight = function(_)
|
||||||
|
return { { group = "CmpItemMenu" } }
|
||||||
|
end
|
||||||
|
},
|
||||||
|
label = {
|
||||||
|
text = function(ctx)
|
||||||
|
return colormenu.blink_components_text(ctx)
|
||||||
|
end,
|
||||||
|
highlight = function(ctx)
|
||||||
|
return colormenu.blink_components_highlight(ctx)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
kind = {
|
||||||
|
-- these highlights are technically for nvim-cmp, but they're
|
||||||
|
-- built into my colorscheme so I don"t mind using them here
|
||||||
|
highlight = function(ctx)
|
||||||
|
return {
|
||||||
|
{ group = "CmpItemKind"..ctx.kind, priority = 20000 }
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
ghost_text = {
|
||||||
|
enabled = true
|
||||||
|
},
|
||||||
|
|
||||||
|
-- documentation should show up immediately
|
||||||
|
documentation = {
|
||||||
|
auto_show = true,
|
||||||
|
auto_show_delay_ms = 0,
|
||||||
|
window = {
|
||||||
|
border = vim.g.border_style
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- I like the default command line completion
|
||||||
|
cmdline = {
|
||||||
|
enabled = false
|
||||||
|
},
|
||||||
|
|
||||||
|
-- signature support is necessary
|
||||||
|
signature = {
|
||||||
|
enabled = true,
|
||||||
|
window = {
|
||||||
|
border = vim.g.border_style
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- TODO: find a way to make my fancy luasnip snippets with multiple
|
||||||
|
-- triggers not look stupid e.g. "fn\|main" for a function that could
|
||||||
|
-- be triggered by fn or main
|
||||||
|
snippets = {
|
||||||
|
preset = "luasnip"
|
||||||
|
},
|
||||||
|
|
||||||
|
sources = {
|
||||||
|
default = { "lsp", "path", "snippets", "buffer" }
|
||||||
|
},
|
||||||
|
|
||||||
|
fuzzy = {
|
||||||
|
implementation = "prefer_rust_with_warning",
|
||||||
|
sorts = {
|
||||||
|
"score",
|
||||||
|
"sort_text"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
@ -1,138 +0,0 @@
|
|||||||
local lsp = require("core.lsp.functions")
|
|
||||||
|
|
||||||
return { "hrsh7th/nvim-cmp",
|
|
||||||
requires = {
|
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
"lukas-reineke/cmp-under-comparator", -- better results
|
|
||||||
"xzbdmw/colorful-menu.nvim" -- fancy colors
|
|
||||||
},
|
|
||||||
|
|
||||||
-- suppliers for completions (they require nvim-cmp to be loaded before they are)
|
|
||||||
deps = {
|
|
||||||
"hrsh7th/cmp-buffer", -- buffers
|
|
||||||
"FelipeLema/cmp-async-path", -- path
|
|
||||||
{ "hrsh7th/cmp-nvim-lsp",
|
|
||||||
function()
|
|
||||||
-- add lsp capabilities
|
|
||||||
lsp.add_capabilities(require("cmp_nvim_lsp").default_capabilities())
|
|
||||||
end
|
|
||||||
}, -- lsp
|
|
||||||
"hrsh7th/cmp-nvim-lsp-signature-help", -- completion information
|
|
||||||
{ "L3MON4D3/cmp-luasnip-choice", -- luasnip
|
|
||||||
requires = "L3MON4D3/LuaSnip"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
function()
|
|
||||||
local cmp = require("cmp")
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
|
|
||||||
-- setup cmp
|
|
||||||
cmp.setup {
|
|
||||||
-- disable when in comments
|
|
||||||
enabled = function()
|
|
||||||
local context = require("cmp.config.context")
|
|
||||||
if vim.api.nvim_get_mode().mode == "c" then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return not context.in_treesitter_capture("comment")
|
|
||||||
and not context.in_syntax_group("Comment")
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- completion sources
|
|
||||||
sources = cmp.config.sources {
|
|
||||||
{ name = "nvim_lsp", priority = 999 },
|
|
||||||
{ name = "luasnip_choice", priority = 750 },
|
|
||||||
{ name = "buffer", max_item_count = 3 },
|
|
||||||
{ name = "async_path", max_item_count = 5 },
|
|
||||||
{ name = "neorg" },
|
|
||||||
{ name = "nvim_lsp_signature_help" }
|
|
||||||
},
|
|
||||||
|
|
||||||
-- how to sort results
|
|
||||||
sorting = {
|
|
||||||
comparators = {
|
|
||||||
cmp.config.compare.exact,
|
|
||||||
cmp.config.compare.offset,
|
|
||||||
cmp.config.compare.score,
|
|
||||||
require("cmp-under-comparator").under,
|
|
||||||
cmp.config.compare.kind,
|
|
||||||
cmp.config.compare.sort_text,
|
|
||||||
cmp.config.compare.length,
|
|
||||||
cmp.config.compare.order,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
-- appearance of window
|
|
||||||
window = {
|
|
||||||
completion = {
|
|
||||||
scrollbar = false,
|
|
||||||
border = vim.g.border_style,
|
|
||||||
winhighlight = "Normal:WinBarNC,FloatBorder:WinBarNC,Search:WinBarNC",
|
|
||||||
},
|
|
||||||
documentation = {
|
|
||||||
border = vim.g.border_style,
|
|
||||||
winhighlight = "Normal:WinBarNC,FloatBorder:WinBarNC,Search:WinBarNC",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
-- position of window
|
|
||||||
view = {
|
|
||||||
entries = {
|
|
||||||
name = "custom",
|
|
||||||
selection_order = "near_cursor"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
-- formatting of content
|
|
||||||
formatting = {
|
|
||||||
fields = { "menu", "abbr", "kind" },
|
|
||||||
format = function(entry, item)
|
|
||||||
local hl_info = require("colorful-menu").cmp_highlights(entry)
|
|
||||||
local menu_icon = {
|
|
||||||
nvim_lsp = "λ",
|
|
||||||
luasnip = "%",
|
|
||||||
buffer = "@",
|
|
||||||
path = "#",
|
|
||||||
async_path = "#"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- add a little icon
|
|
||||||
item.menu = menu_icon[entry.source.name]
|
|
||||||
|
|
||||||
-- add highlights
|
|
||||||
if hl_info ~= nil then
|
|
||||||
item.abbr_hl_group = hl_info.highlights
|
|
||||||
item.abbr = hl_info.text
|
|
||||||
end
|
|
||||||
|
|
||||||
return item
|
|
||||||
end
|
|
||||||
},
|
|
||||||
|
|
||||||
experimental = {
|
|
||||||
ghost_text = true
|
|
||||||
},
|
|
||||||
|
|
||||||
-- snippet integration
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
luasnip.lsp_expand(args.body)
|
|
||||||
end
|
|
||||||
},
|
|
||||||
|
|
||||||
-- mappings
|
|
||||||
mapping = cmp.mapping.preset.insert {
|
|
||||||
["<C-y>"] = cmp.mapping.confirm {
|
|
||||||
select = true
|
|
||||||
},
|
|
||||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
|
||||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
|
||||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
|
||||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
|
||||||
["<ESC>"] = cmp.mapping.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
}
|
|
27
lua/conf/plugins/dap-vtxt.lua
Normal file
27
lua/conf/plugins/dap-vtxt.lua
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
return { "theHamsta/nvim-dap-virtual-text",
|
||||||
|
requires = {
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
"mfussenegger/nvim-dap"
|
||||||
|
},
|
||||||
|
function()
|
||||||
|
require("nvim-dap-virtual-text").setup {
|
||||||
|
virt_text_pos = vim.fn.has("nvim-0.10") == 1 and "inline" or "eol",
|
||||||
|
|
||||||
|
--- A callback that determines how a variable is displayed or whether it should be omitted
|
||||||
|
--- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
|
||||||
|
--- @param buf number
|
||||||
|
--- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
|
||||||
|
--- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`)
|
||||||
|
--- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text
|
||||||
|
--- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed
|
||||||
|
display_callback = function(variable, buf, stackframe, node, options)
|
||||||
|
-- by default, strip out new line characters
|
||||||
|
if options.virt_text_pos == "inline" then
|
||||||
|
return " = "..variable.value:gsub("%s+", " ")
|
||||||
|
else
|
||||||
|
return variable.name.." = "..variable.value:gsub("%s+", " ")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
@ -1,50 +1,98 @@
|
|||||||
local misc = require("core.misc")
|
local misc = require("core.misc")
|
||||||
local map = misc.map
|
local map = misc.map
|
||||||
|
|
||||||
|
--- select a program to execute
|
||||||
|
---@return thread coroutine containing the picker
|
||||||
|
local function select_program()
|
||||||
|
return coroutine.create(function(coro)
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
|
local entries = vim.fn.readdir(".", [[v:val !~ '^\.']])
|
||||||
|
vim.ui.select(entries, { prompt = "Select the executable to run:" },
|
||||||
|
function(choice)
|
||||||
|
coroutine.resume(coro, choice)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local keymap_restore = {}
|
||||||
|
--- make the default hover binding work for nvim-dap instead of lsp
|
||||||
|
local function set_hover_bind()
|
||||||
|
for _, buf in pairs(vim.api.nvim_list_bufs()) do
|
||||||
|
local keymaps = vim.api.nvim_buf_get_keymap(buf, 'n')
|
||||||
|
for _, keymap in pairs(keymaps) do
|
||||||
|
if keymap.lhs == "K" then
|
||||||
|
table.insert(keymap_restore, keymap)
|
||||||
|
vim.api.nvim_buf_del_keymap(buf, 'n', 'K')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.keymap.set('n', 'K', require("dap.ui.widgets").hover,
|
||||||
|
{ silent = true })
|
||||||
|
end
|
||||||
|
|
||||||
|
--- revert the hover bind back to whatever it was
|
||||||
|
local function unset_hover_bind()
|
||||||
|
for _, keymap in pairs(keymap_restore) do
|
||||||
|
if keymap.rhs then
|
||||||
|
vim.api.nvim_buf_set_keymap(keymap.buffer, keymap.mode, keymap.lhs,
|
||||||
|
keymap.rhs, { silent = keymap.silent == 1 })
|
||||||
|
elseif keymap.callback then
|
||||||
|
vim.keymap.set(keymap.mode, keymap.lhs, keymap.callback,
|
||||||
|
{ buffer = keymap.buffer, silent = keymap.silent == 1 })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
keymap_restore = {}
|
||||||
|
end
|
||||||
|
|
||||||
return { "mfussenegger/nvim-dap",
|
return { "mfussenegger/nvim-dap",
|
||||||
requires = {
|
requires = {
|
||||||
"williamboman/mason.nvim",
|
"mason-org/mason.nvim",
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim"
|
||||||
},
|
},
|
||||||
disable = not vim.fn.has("nvim-0.8.0"),
|
disable = not vim.fn.has("nvim-0.9.5"),
|
||||||
branch = "0.8.0",
|
branch = "0.10.0",
|
||||||
function()
|
function()
|
||||||
|
|
||||||
local dap = require("dap")
|
local dap = require("dap")
|
||||||
|
|
||||||
local codelldb_port = 13000
|
-- define codelldb
|
||||||
dap.adapters.codelldb = {
|
dap.adapters.codelldb = {
|
||||||
type = "server",
|
type = "executable",
|
||||||
host = "127.0.0.1",
|
command = "codelldb",
|
||||||
port = codelldb_port,
|
|
||||||
executable = {
|
|
||||||
command = require("mason-registry").get_package("codelldb"):get_install_path().."/codelldb",
|
|
||||||
args = { "--port", codelldb_port }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- define the c configuration for codelldb
|
||||||
dap.configurations.c = {
|
dap.configurations.c = {
|
||||||
{
|
{
|
||||||
name = "LLDB: Launch",
|
name = "Launch file",
|
||||||
type = "codelldb",
|
type = "codelldb",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
program = function()
|
program = select_program,
|
||||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd().."/", "file")
|
|
||||||
end,
|
|
||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
stopOnEntry = false,
|
stopOnEntry = false
|
||||||
args = {},
|
|
||||||
console = "integratedTerminal"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- and define them for cpp, zig, and rust
|
||||||
|
dap.configurations.cpp = dap.configurations.c
|
||||||
|
dap.configurations.zig = dap.configurations.c
|
||||||
|
dap.configurations.rust = dap.configurations.c
|
||||||
|
|
||||||
|
-- keybinds
|
||||||
map("n", "<Leader>ec", dap.continue, { desc = "dap continue " })
|
map("n", "<Leader>ec", dap.continue, { desc = "dap continue " })
|
||||||
map("n", "<Leader>el", dap.run_last, { desc = "dap run last" })
|
map("n", "<Leader>el", dap.run_last, { desc = "dap run last" })
|
||||||
map("n", "<Leader>et", dap.terminate, { desc = "dap terminate " })
|
map("n", "<Leader>et", function()
|
||||||
|
dap.terminate()
|
||||||
|
unset_hover_bind()
|
||||||
|
end, { desc = "dap terminate " })
|
||||||
map("n", "<Leader>eb", require("dap.breakpoints").toggle, { desc = "dap toggle breakpoint" })
|
map("n", "<Leader>eb", require("dap.breakpoints").toggle, { desc = "dap toggle breakpoint" })
|
||||||
map("n", "<Leader>e]", dap.step_over, { desc = "dap step over" })
|
map("n", "<Leader>e]", dap.step_over, { desc = "dap step over" })
|
||||||
map("n", "<Leader>e[", dap.step_back, { desc = "dap step back" })
|
map("n", "<Leader>e[", dap.step_back, { desc = "dap step back" })
|
||||||
map("n", "<Leader>er", dap.repl.toggle, { desc = "dap repl toggle" })
|
map("n", "<Leader>er", dap.repl.toggle, { desc = "dap repl toggle" })
|
||||||
map("n", "<Leader>eR", dap.restart, { desc = "dap restart" })
|
map("n", "<Leader>eR", dap.restart, { desc = "dap restart" })
|
||||||
|
|
||||||
|
-- events
|
||||||
|
dap.listeners.after['event_initialized']['me'] = set_hover_bind
|
||||||
|
dap.listeners.after['event_terminated']['me'] = unset_hover_bind
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -1,150 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
|
||||||
local lsp = require("core.lsp.functions")
|
|
||||||
local map, auto = misc.map, misc.auto
|
|
||||||
|
|
||||||
return { "mfussenegger/nvim-jdtls",
|
return { "mfussenegger/nvim-jdtls",
|
||||||
disable = not vim.fn.has("nvim-0.6.0"),
|
disable = not vim.fn.has("nvim-0.6.0"),
|
||||||
requires = "mfussenegger/nvim-dap",
|
requires = "mfussenegger/nvim-dap"
|
||||||
function()
|
|
||||||
auto("FileType", {
|
|
||||||
pattern = "java",
|
|
||||||
callback = function()
|
|
||||||
local jdtls = require("jdtls")
|
|
||||||
local jdtls_install = require("mason-registry").get_package("jdtls"):get_install_path()
|
|
||||||
|
|
||||||
-- make sure to check if things with 💀 need updating
|
|
||||||
local config = {
|
|
||||||
cmd = {
|
|
||||||
"/usr/lib/jvm/openjdk21/bin/java", -- 💀
|
|
||||||
"-jar", vim.fn.glob(jdtls_install.."/plugins/org.eclipse.equinox.launcher_*.jar"), -- 💀
|
|
||||||
"-configuration", jdtls_install.."/config_linux",
|
|
||||||
"-data", vim.fn.stdpath("cache").."/nvim-jdtls",
|
|
||||||
|
|
||||||
"--add-modules=ALL-SYSTEM",
|
|
||||||
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
|
|
||||||
"--add-opens", "java.base/java.util=ALL-UNNAMED",
|
|
||||||
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
|
||||||
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
|
||||||
"-Dlog.level=ALL",
|
|
||||||
"-Dlog.protocol=true",
|
|
||||||
"-Dosgi.bundles.defaultStartLevel=4",
|
|
||||||
"-Xmx1G",
|
|
||||||
},
|
|
||||||
root_dir = vim.fs.dirname(vim.fs.find({
|
|
||||||
"gradlew",
|
|
||||||
".git",
|
|
||||||
"mvnw",
|
|
||||||
"settings.gradle", -- Gradle (multi-project)
|
|
||||||
"settings.gradle.kts", -- Gradle (multi-project)
|
|
||||||
"build.xml", -- Ant
|
|
||||||
"pom.xml", -- Maven
|
|
||||||
}, { upward = true })[1]),
|
|
||||||
|
|
||||||
-- don"t print out status messages
|
|
||||||
handlers = {
|
|
||||||
["language/status"] = function() end
|
|
||||||
},
|
|
||||||
|
|
||||||
on_attach = function(_, bufnr)
|
|
||||||
-- add some jdtls specific mappings
|
|
||||||
local opts = { buffer = bufnr }
|
|
||||||
map("n", "cri", jdtls.organize_imports, opts)
|
|
||||||
map("n", "crv", jdtls.extract_variable, opts)
|
|
||||||
map("n", "crc", jdtls.extract_constant, opts)
|
|
||||||
map("x", "crv", function() jdtls.extract_variable(true) end, opts)
|
|
||||||
map("x", "crc", function() jdtls.extract_constant(true) end, opts)
|
|
||||||
map("x", "crm", function() jdtls.extract_method(true) end, opts)
|
|
||||||
|
|
||||||
pcall(vim.lsp.codelens.refresh)
|
|
||||||
auto("BufWritePost", {
|
|
||||||
buffer = bufnr,
|
|
||||||
desc = "refresh codelens",
|
|
||||||
callback = function()
|
|
||||||
pcall(vim.lsp.codelens.refresh)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
capabilities = lsp.capabilities
|
|
||||||
}
|
|
||||||
|
|
||||||
-- generate the path to the java file(s)
|
|
||||||
---@type string|nil
|
|
||||||
local cache_path = vim.fs.joinpath(vim.fn.stdpath("cache"), "/JavaVersion.class")
|
|
||||||
---@type string|nil
|
|
||||||
local src_path = vim.fs.joinpath(vim.fn.stdpath("config"), "/extras/JavaVersion.java")
|
|
||||||
|
|
||||||
-- if either path is invalid
|
|
||||||
if not cache_path or not src_path then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--- build a cache of the JavaVersion code
|
|
||||||
local function build_cache()
|
|
||||||
-- check if we have javac
|
|
||||||
vim.system({ "javac" }, {}, function(out)
|
|
||||||
if out.code == 127 then
|
|
||||||
cache_path = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- compile our code
|
|
||||||
vim.system({ "javac", src_path, "-d", vim.fn.stdpath("cache") }, {}, function(out)
|
|
||||||
if out.code ~= 0 then
|
|
||||||
cache_path = nil
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if we have a compiled version of JavaVersion
|
|
||||||
local f, _ = io.open(cache_path, "r")
|
|
||||||
if not f then -- if we don"t have a cache
|
|
||||||
build_cache()
|
|
||||||
else
|
|
||||||
io.close(f)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check the java version
|
|
||||||
local buffer = {}
|
|
||||||
vim.fn.jobstart({
|
|
||||||
config.cmd[1],
|
|
||||||
(cache_path and "JavaVersion") or src_path
|
|
||||||
}, {
|
|
||||||
cwd = vim.fn.stdpath("cache"),
|
|
||||||
stdin = nil,
|
|
||||||
on_stdout = function(_, data, _)
|
|
||||||
table.insert(buffer, table.concat(data))
|
|
||||||
end,
|
|
||||||
on_exit = function(_, exit_code, _)
|
|
||||||
local v = vim.version.parse(table.concat(buffer))
|
|
||||||
|
|
||||||
-- if there"s an error, no version info, or the java version is
|
|
||||||
-- less than 17 stop the lsp from starting
|
|
||||||
if exit_code ~= 0 then
|
|
||||||
vim.notify(string.format(
|
|
||||||
"java version check failed: exit code %s", exit_code),
|
|
||||||
vim.log.levels.ERROR, { title = misc.appid })
|
|
||||||
vim.notify(string.format(
|
|
||||||
"%s", vim.inspect(buffer)),
|
|
||||||
vim.log.levels.ERROR, { title = misc.appid })
|
|
||||||
return
|
|
||||||
elseif not v then
|
|
||||||
vim.notify("no java version info found", vim.log.levels.ERROR,
|
|
||||||
{ title = misc.appid })
|
|
||||||
return
|
|
||||||
elseif v.major < 17 then
|
|
||||||
vim.notify(string.format(
|
|
||||||
"java version %s < 17.0.0 Cannot run jdtls, bailing out",
|
|
||||||
v[1].."."..v[2].."."..v[3]),
|
|
||||||
vim.log.levels.ERROR, { title = misc.appid })
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- start lsp
|
|
||||||
jdtls.start_or_attach(config)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
17
lua/conf/plugins/lspconfig.lua
Normal file
17
lua/conf/plugins/lspconfig.lua
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
return { "neovim/nvim-lspconfig",
|
||||||
|
disable = not vim.fn.has("nvim-0.10.0"),
|
||||||
|
requires = {
|
||||||
|
"mason-org/mason.nvim",
|
||||||
|
"mason-org/mason-lspconfig.nvim"
|
||||||
|
},
|
||||||
|
function()
|
||||||
|
require("core.lsp.functions").setup()
|
||||||
|
require("mason-lspconfig").setup {
|
||||||
|
ensure_added = {
|
||||||
|
"clangd",
|
||||||
|
"lua_ls",
|
||||||
|
"jdtls"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
@ -2,7 +2,7 @@ local misc = require("core.misc")
|
|||||||
local map = misc.map
|
local map = misc.map
|
||||||
|
|
||||||
return { "L3MON4D3/LuaSnip",
|
return { "L3MON4D3/LuaSnip",
|
||||||
branch = "v2.3.0",
|
branch = "v2.4.0",
|
||||||
disable = not vim.fn.has("nvim-0.7.0"),
|
disable = not vim.fn.has("nvim-0.7.0"),
|
||||||
config = function()
|
config = function()
|
||||||
vim.cmd("make install_jsregexp")
|
vim.cmd("make install_jsregexp")
|
||||||
|
@ -1,136 +0,0 @@
|
|||||||
local misc = require("core.misc")
|
|
||||||
local lsp = require("core.lsp.functions")
|
|
||||||
local map = misc.map
|
|
||||||
|
|
||||||
return { "williamboman/mason-lspconfig.nvim",
|
|
||||||
requires = {
|
|
||||||
"williamboman/mason.nvim",
|
|
||||||
{ "neovim/nvim-lspconfig",
|
|
||||||
disable = not vim.fn.has("nvim-0.8.0"),
|
|
||||||
function()
|
|
||||||
lsp.setup()
|
|
||||||
end
|
|
||||||
},
|
|
||||||
|
|
||||||
-- these two update some lsp capabilities and therefore must be run first
|
|
||||||
-- "hrsh7th/cmp-nvim-lsp",
|
|
||||||
-- "kevinhwang91/nvim-ufo"
|
|
||||||
},
|
|
||||||
function()
|
|
||||||
local lspconfig = require("lspconfig")
|
|
||||||
local util = require("lspconfig.util")
|
|
||||||
|
|
||||||
-- setup language servers
|
|
||||||
require("mason-lspconfig").setup {
|
|
||||||
ensure_installed = {
|
|
||||||
"lua_ls",
|
|
||||||
"clangd",
|
|
||||||
"jdtls",
|
|
||||||
"phpactor",
|
|
||||||
"html",
|
|
||||||
"cssls",
|
|
||||||
"bashls",
|
|
||||||
"zls"
|
|
||||||
-- "asm-lsp", -- seems to be broken
|
|
||||||
},
|
|
||||||
|
|
||||||
-- setup all handlers
|
|
||||||
handlers = {
|
|
||||||
function(server_name)
|
|
||||||
lspconfig[server_name].setup {}
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- setup luals
|
|
||||||
["lua_ls"] = function(server_name)
|
|
||||||
local root_files = { ".luarc.json", ".luarc.jsonc", ".luacheckrc",
|
|
||||||
".stylua.toml", "stylua.toml", "selene.toml", "selene.yml",
|
|
||||||
"README.md"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- FIXME: luals seems to start up twice and sends back twice the
|
|
||||||
-- completions (one configured with the below settings and one without)
|
|
||||||
lspconfig[server_name].setup {
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
diagnostics = {
|
|
||||||
globals = { "vim", "mp" }
|
|
||||||
},
|
|
||||||
runtime = {
|
|
||||||
version = "LuaJIT"
|
|
||||||
},
|
|
||||||
format = {
|
|
||||||
enable = false
|
|
||||||
},
|
|
||||||
workspace = {
|
|
||||||
checkThirdParty = false,
|
|
||||||
library = {
|
|
||||||
vim.env.VIMRUNTIME
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
root_dir = function(fname)
|
|
||||||
local root = util.root_pattern(unpack(root_files))(fname)
|
|
||||||
if root and root ~= vim.env.HOME then
|
|
||||||
return root
|
|
||||||
end
|
|
||||||
|
|
||||||
root = util.root_pattern("lua/")(fname)
|
|
||||||
if root then
|
|
||||||
return root
|
|
||||||
end
|
|
||||||
return util.find_git_ancestor(fname)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- setup clangd
|
|
||||||
["clangd"] = function(server_name)
|
|
||||||
lspconfig[server_name].setup {
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
-- add some clangd specific mappings
|
|
||||||
local opts = { buffer = bufnr }
|
|
||||||
map("n", "<leader>o", "<cmd>ClangdSwitchSourceHeader<CR>", opts)
|
|
||||||
end,
|
|
||||||
|
|
||||||
cmd = {
|
|
||||||
"clangd",
|
|
||||||
"--background-index",
|
|
||||||
"--clang-tidy",
|
|
||||||
"--header-insertion=iwyu",
|
|
||||||
"--completion-style=detailed",
|
|
||||||
"--function-arg-placeholders",
|
|
||||||
"--fallback-style=llvm"
|
|
||||||
},
|
|
||||||
init_options = {
|
|
||||||
usePlaceholders = true,
|
|
||||||
clangdFileStatus = true,
|
|
||||||
fallback_flags = {
|
|
||||||
"-xc" -- makes clangd think we"re using c instead of c++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- disable it, we start this using nvim-jdtls
|
|
||||||
["jdtls"] = function(_) end,
|
|
||||||
|
|
||||||
-- setup basedpyright
|
|
||||||
["basedpyright"] = function(server_name)
|
|
||||||
lspconfig[server_name].setup {
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
-- add some basedpyright specific mappings
|
|
||||||
local opts = { buffer = bufnr }
|
|
||||||
map("n", "cri", "<cmd>PyrightOrganizeImports<CR>", opts)
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
},
|
|
||||||
|
|
||||||
["openscad_lsp"] = function(server_name)
|
|
||||||
lspconfig[server_name].setup {}
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
return { "williamboman/mason.nvim",
|
return { "mason-org/mason.nvim",
|
||||||
disable = not vim.fn.has("nvim-0.7.0"),
|
disable = not vim.fn.has("nvim-0.7.0"),
|
||||||
function()
|
function()
|
||||||
local mason = require("mason")
|
local mason = require("mason")
|
||||||
|
@ -13,29 +13,17 @@ return { "mellow-theme/mellow.nvim",
|
|||||||
["NormalFloat"] = { fg = c.fg, bg = "#111111" },
|
["NormalFloat"] = { fg = c.fg, bg = "#111111" },
|
||||||
["FloatBorder"] = { link = "NormalFloat" },
|
["FloatBorder"] = { link = "NormalFloat" },
|
||||||
|
|
||||||
-- neorg headings, looks extra good with lukas-reineke/headlines.nvim
|
-- make diagnostics have an undercurl
|
||||||
["@neorg.headings.1.title"] = { fg = c.yellow, bg = "#2a211c" },
|
["DiagnosticUnderlineError"] = { fg = c.red, undercurl = true },
|
||||||
["@neorg.headings.1.icon"] = { link = "@neorg.headings.1.title" },
|
["DiagnosticUnderlineWarn"] = { fg = c.yellow, undercurl = true },
|
||||||
|
["DiagnosticUnderlineInfo"] = { fg = c.blue, undercurl = true },
|
||||||
["@neorg.headings.2.title"] = { fg = c.blue, bg = "#201e25" },
|
["DiagnosticUnderlineHint"] = { fg = c.cyan, undercurl = true },
|
||||||
["@neorg.headings.2.icon"] = { link = "@neorg.headings.2.title" },
|
|
||||||
|
|
||||||
["@neorg.headings.3.title"] = { fg = c.cyan, bg = "#2b1b20" },
|
|
||||||
["@neorg.headings.3.icon"] = { link = "@neorg.headings.3.title" },
|
|
||||||
|
|
||||||
["@neorg.headings.4.title"] = { fg = c.green, bg = "#1d201e" },
|
|
||||||
["@neorg.headings.4.icon"] = { link = "@neorg.headings.4.title" },
|
|
||||||
|
|
||||||
["@neorg.headings.5.title"] = { fg = c.magenta, bg = "#251a21" },
|
|
||||||
["@neorg.headings.5.icon"] = { link = "@neorg.headings.5.title" },
|
|
||||||
|
|
||||||
["@neorg.headings.6.title"] = { fg = c.white, bg = "#212126" },
|
|
||||||
["@neorg.headings.6.icon"] = { link = "@neorg.headings.6.title" },
|
|
||||||
|
|
||||||
-- make blink actually look nice
|
-- make blink actually look nice
|
||||||
["BlinkCmpMenu"] = { bg = c.bg_dark },
|
["BlinkCmpMenu"] = { link = "NormalFloat" },
|
||||||
["BlinkCmpMenuBorder"] = { link = "BlinkCmpMenu" },
|
["BlinkCmpMenuBorder"] = { link = "BlinkCmpMenu" },
|
||||||
["BlinkCmpMenuSelection"] = { bg = c.gray02 }
|
["BlinkCmpMenuSelection"] = { bg = c.gray01 },
|
||||||
|
["BlinkCmpLabelDeprecated"] = { link = "CmpItemAbbrDeprecated" }
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -1,146 +0,0 @@
|
|||||||
-- WARNING: neorg does some pretty stupid stuff when it comes to the plugins it
|
|
||||||
-- wants (using luarocks), in order to get around all that bullshit I"ve
|
|
||||||
-- manually added it"s dependencies. Because I don"t want this to randomly break
|
|
||||||
-- I"ve also pinned neorg to the latest working version that I"ve messed around
|
|
||||||
-- with.
|
|
||||||
--
|
|
||||||
-- NOTE: for my future self to update this thingy while not breaking
|
|
||||||
-- dependencies take a look at the build.lua for versioning info. Also make sure
|
|
||||||
-- to check the release notes on github for info on breaking changes.
|
|
||||||
|
|
||||||
local workspace_cache
|
|
||||||
if not vim.fs then
|
|
||||||
workspace_cache = vim.fn.stdpath("data").."/neorg-workspace-cache.lua"
|
|
||||||
else
|
|
||||||
workspace_cache = vim.fs.joinpath(vim.fn.stdpath("data"), "neorg-workspace-cache.lua")
|
|
||||||
end
|
|
||||||
|
|
||||||
--- populate neorg workspaces from path or cache
|
|
||||||
---@param path string path to populate workspaces from
|
|
||||||
---@param cache boolean? if true will re populate the cache from the fs
|
|
||||||
---@return table workspaces
|
|
||||||
local function populate_workspaces(path, cache)
|
|
||||||
local workspaces = {}
|
|
||||||
cache = cache or false
|
|
||||||
|
|
||||||
if vim.fn.filereadable(workspace_cache) == 1 and not cache then
|
|
||||||
local ok, ret = pcall(dofile, workspace_cache)
|
|
||||||
if ok and type(ret) == "table" then
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- loop through all files in path if path is not empty
|
|
||||||
if vim.fn.empty(vim.fn.glob(path)) == 0 then
|
|
||||||
for n, t in vim.fs.dir(path) do
|
|
||||||
if string.sub(n, 1, 1) == "." or (t ~= "directory" and t ~= "link") then
|
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
-- make sure this still works if the last charachter in the path isn"t a "/"
|
|
||||||
workspaces[n] = (string.sub(path, #path, #path) == "/") and path..n or path.."/"..n
|
|
||||||
::continue::
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- write data to cachefile
|
|
||||||
local f = io.open(workspace_cache, "w+")
|
|
||||||
if not f then
|
|
||||||
return workspaces
|
|
||||||
end
|
|
||||||
|
|
||||||
f:write("return")
|
|
||||||
local ret = vim.inspect(workspaces)
|
|
||||||
if type(ret) == "string" then
|
|
||||||
f:write(ret)
|
|
||||||
else
|
|
||||||
f:write("false")
|
|
||||||
end
|
|
||||||
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
return workspaces
|
|
||||||
end
|
|
||||||
|
|
||||||
return { "nvim-neorg/neorg",
|
|
||||||
disable = not vim.fn.has("nvim-0.10.0"),
|
|
||||||
branch = "v9.3.0",
|
|
||||||
requires = {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
"folke/zen-mode.nvim",
|
|
||||||
"hrsh7th/nvim-cmp",
|
|
||||||
{ "nvim-neorg/neorg-telescope",
|
|
||||||
requires = "nvim-telescope/telescope.nvim"
|
|
||||||
},
|
|
||||||
|
|
||||||
-- NOTE: these are usually installed by neorg via luarocks, the versions
|
|
||||||
-- were picked based on the neorg-scm-1.rockspec found in the root of the
|
|
||||||
-- neorg repo
|
|
||||||
{ "nvim-neotest/nvim-nio",
|
|
||||||
branch = "v1.7.0"
|
|
||||||
},
|
|
||||||
{ "nvim-neorg/lua-utils.nvim",
|
|
||||||
branch = "v1.0.2"
|
|
||||||
},
|
|
||||||
{ "MunifTanjim/nui.nvim",
|
|
||||||
branch = "0.3.0"
|
|
||||||
},
|
|
||||||
{ "pysan3/pathlib.nvim",
|
|
||||||
branch = "v2.2.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
function()
|
|
||||||
local wsphome = (os.getenv("XDG_DOCUMENTS_DIR") or
|
|
||||||
(os.getenv("HOME").."/Documents")).."/notes/"
|
|
||||||
|
|
||||||
require("neorg").setup {
|
|
||||||
load = {
|
|
||||||
-- not sure how to sort the modules so ima just put the empty ones first
|
|
||||||
["core.defaults"] = {},
|
|
||||||
["core.export"] = {},
|
|
||||||
["core.export.markdown"] = {},
|
|
||||||
["core.integrations.telescope"] = {},
|
|
||||||
["core.summary"] = {},
|
|
||||||
["core.ui.calendar"] = {},
|
|
||||||
|
|
||||||
["core.completion"] = {
|
|
||||||
config = {
|
|
||||||
engine = "nvim-cmp"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
["core.concealer"] = {
|
|
||||||
config = {
|
|
||||||
folds = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
["core.dirman"] = {
|
|
||||||
config = {
|
|
||||||
-- a list of available workspaces are generated at runtime >:)
|
|
||||||
workspaces = populate_workspaces(wsphome)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
["core.esupports.metagen"] = {
|
|
||||||
config = {
|
|
||||||
type = "auto"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
["core.presenter"] = {
|
|
||||||
config = {
|
|
||||||
zen_mode = "zen-mode"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
["core.qol.toc"] = {
|
|
||||||
config = {
|
|
||||||
close_after_use = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
["core.tangle"] = {
|
|
||||||
config = {
|
|
||||||
tangle_on_write = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
}
|
|
@ -25,7 +25,7 @@ return { "nvim-treesitter/nvim-treesitter",
|
|||||||
enable = true,
|
enable = true,
|
||||||
|
|
||||||
disable = function(lang, _)
|
disable = function(lang, _)
|
||||||
-- disable indenting in php (it"s more broken with than without)
|
-- disable indenting in php (it's more broken with than without)
|
||||||
return table.contains(({
|
return table.contains(({
|
||||||
"php"
|
"php"
|
||||||
}), lang)
|
}), lang)
|
||||||
@ -39,7 +39,7 @@ return { "nvim-treesitter/nvim-treesitter",
|
|||||||
additional_vim_regex_highlighting = true,
|
additional_vim_regex_highlighting = true,
|
||||||
|
|
||||||
disable = function(lang, buf)
|
disable = function(lang, buf)
|
||||||
-- disable in some files where vim"s builtin highlighting is better
|
-- disable in some files where vim's builtin highlighting is better
|
||||||
if table.contains(({
|
if table.contains(({
|
||||||
"diff", "tex"
|
"diff", "tex"
|
||||||
}), lang) then
|
}), lang) then
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
local misc = require("core.misc")
|
local misc = require("core.misc")
|
||||||
local map, include = misc.map, misc.include
|
local map, auto = misc.map, misc.auto
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@ -34,6 +34,11 @@ local list_opts = {
|
|||||||
---@diagnostic disable-next-line: assign-type-mismatch
|
---@diagnostic disable-next-line: assign-type-mismatch
|
||||||
local location_opts = vim.tbl_deep_extend("force", list_opts, {})
|
local location_opts = vim.tbl_deep_extend("force", list_opts, {})
|
||||||
|
|
||||||
|
-- disable the default keybinds (they're bad)
|
||||||
|
for _, bind in ipairs({ "grn", "gra", "gri", "grr" }) do
|
||||||
|
pcall(vim.keymap.del, "n", bind)
|
||||||
|
end
|
||||||
|
|
||||||
--- setup basic options on lsp attach
|
--- setup basic options on lsp attach
|
||||||
---@param bufnr number buffer number
|
---@param bufnr number buffer number
|
||||||
local function attach(bufnr)
|
local function attach(bufnr)
|
||||||
@ -55,27 +60,18 @@ local function attach(bufnr)
|
|||||||
|
|
||||||
-- Diagnostics
|
-- Diagnostics
|
||||||
map("n", "[d", function()
|
map("n", "[d", function()
|
||||||
if not vim.fn.has("nvim-0.11") then
|
vim.diagnostic.jump({ count = -1 })
|
||||||
vim.diagnostic.goto_prev()
|
|
||||||
else
|
|
||||||
vim.diagnostic.jump({ count = -1 })
|
|
||||||
end
|
|
||||||
end, opts)
|
end, opts)
|
||||||
map("n", "]d", function()
|
map("n", "]d", function()
|
||||||
if not vim.fn.has("nvim-0.11") then
|
vim.diagnostic.jump({ count = 1 })
|
||||||
vim.diagnostic.goto_next()
|
|
||||||
else
|
|
||||||
vim.diagnostic.jump({ count = 1 })
|
|
||||||
end
|
|
||||||
end, opts)
|
end, opts)
|
||||||
-- map("n", "qD", vim.diagnostic.setqflist, opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
vim.diagnostic.config {
|
vim.diagnostic.config {
|
||||||
virtual_text = false,
|
virtual_text = false,
|
||||||
virtual_lines = {
|
virtual_lines = {
|
||||||
only_current_line = true,
|
only_current_line = true
|
||||||
},
|
},
|
||||||
update_in_insert = false,
|
update_in_insert = false,
|
||||||
underline = true,
|
underline = true,
|
||||||
@ -90,38 +86,17 @@ function M.setup()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if not vim.fn.has("nvim-0.11") then
|
-- set default capabilities and attach function
|
||||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
|
vim.lsp.config['*'] = {
|
||||||
vim.lsp.handlers.hover, { border = vim.g.border_style })
|
capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
}
|
||||||
|
|
||||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
-- make my attach function always run
|
||||||
vim.lsp.handlers.signature_help, { border = vim.g.border_style })
|
auto("LspAttach", {
|
||||||
end
|
|
||||||
|
|
||||||
-- set default capabilities
|
|
||||||
include("lspconfig.util").default_config.capabilities = M.capabilities
|
|
||||||
|
|
||||||
-- run whenever a client attaches
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
|
||||||
callback = function(event)
|
callback = function(event)
|
||||||
-- map keybinds
|
|
||||||
attach(event.buf)
|
attach(event.buf)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- FIXME: I don"t like this way of doing things, there has to be a better way
|
|
||||||
|
|
||||||
--- capabilities that are to be used in lsp servers, for those setup through
|
|
||||||
--- lspconfig, this is already set as the default. Incase there is a server
|
|
||||||
--- not setup through lspconfig this function may be called to receive the
|
|
||||||
--- proper capabilities data.
|
|
||||||
M.capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
|
|
||||||
--- add capabilities to the default capabilities string
|
|
||||||
---@param new_capabilities lsp.ClientCapabilities
|
|
||||||
function M.add_capabilities(new_capabilities)
|
|
||||||
vim.tbl_deep_extend("force", M.capabilities, new_capabilities)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
Reference in New Issue
Block a user