wozers
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
indent_type = "Spaces" # Use spaces instead of tabs
|
indent_type = "Spaces" # Use spaces instead of tabs
|
||||||
indent_width = 2 # Number of spaces per indent level
|
indent_width = 2 # Number of spaces per indent level
|
||||||
quote_style = "ForceDouble" # Always use double quotes for strings
|
quote_style = "ForceDouble" # Always use double quotes for strings
|
||||||
|
call_parentheses = "Always"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require('core.misc')
|
local map_local = core.misc.map_local
|
||||||
local map_local = misc.map_local
|
|
||||||
|
|
||||||
-- sort #includes <> (very jank)
|
-- sort #includes <> (very jank)
|
||||||
-- TODO: rewrite in a semi-sane way
|
-- TODO: rewrite in a semi-sane way
|
||||||
|
1
after/ftplugin/dap-float.lua
Normal file
1
after/ftplugin/dap-float.lua
Normal file
@ -0,0 +1 @@
|
|||||||
|
core.misc.map("n", "q", "<cmd>q<CR>")
|
@ -1,5 +1,7 @@
|
|||||||
local misc = require("core.misc")
|
-- FIXME: the following error is emmitted when starting up jdtls:
|
||||||
local map, auto = misc.map, misc.auto
|
-- ERROR No LSP client found that supports vscode.java.resolveMainClass
|
||||||
|
|
||||||
|
local map, auto = core.misc.map, core.misc.auto
|
||||||
|
|
||||||
local ok, jdtls = pcall(require, "jdtls")
|
local ok, jdtls = pcall(require, "jdtls")
|
||||||
if not ok then
|
if not ok then
|
||||||
@ -8,20 +10,16 @@ if not ok then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- HACK: I don't like using path concatination there *should* be a way to get
|
local jdtls_install = core.mason.get_pkg_path("jdtls")
|
||||||
-- the path from mason
|
local java_dap_install = core.mason.get_pkg_path("java-debug-adapter")
|
||||||
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
|
-- make sure to check if things with 💀 need updating
|
||||||
local config = {
|
local config = {
|
||||||
cmd = {
|
cmd = {
|
||||||
"/usr/lib/jvm/openjdk21/bin/java", -- 💀
|
"/usr/lib/jvm/openjdk21/bin/java", -- 💀
|
||||||
"-jar", -- 💀
|
"-jar", -- 💀
|
||||||
vim.fn.glob(jdtls_install.."/plugins/org.eclipse.equinox.launcher_*.jar"),
|
vim.fn.glob(vim.fs.joinpath(jdtls_install, "plugins/org.eclipse.equinox.launcher_*.jar")),
|
||||||
"-configuration", jdtls_install.."/config_linux",
|
"-configuration", jdtls_install.."config_linux",
|
||||||
"-data", vim.fn.stdpath("cache").."/nvim-jdtls",
|
"-data", vim.fn.stdpath("cache").."/nvim-jdtls",
|
||||||
|
|
||||||
"--add-modules=ALL-SYSTEM",
|
"--add-modules=ALL-SYSTEM",
|
||||||
@ -88,15 +86,13 @@ local config = {
|
|||||||
init_options = {
|
init_options = {
|
||||||
bundles = {
|
bundles = {
|
||||||
vim.fs.joinpath(java_dap_install,
|
vim.fs.joinpath(java_dap_install,
|
||||||
vim.fn.glob("/extension/server/com.microsoft.java.debug.plugin-*.jar",
|
vim.fn.glob("extension/server/com.microsoft.java.debug.plugin-*.jar",
|
||||||
true)
|
true)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- HACK: same hack as before
|
|
||||||
|
|
||||||
-- generate the path to the java file(s)
|
-- generate the path to the java file(s)
|
||||||
---@type string?
|
---@type string?
|
||||||
local cache_path = vim.fs.joinpath(vim.fn.stdpath("cache"),
|
local cache_path = vim.fs.joinpath(vim.fn.stdpath("cache"),
|
||||||
@ -150,20 +146,20 @@ local function version_check()
|
|||||||
if out.code ~= 0 then
|
if out.code ~= 0 then
|
||||||
vim.notify(string.format(
|
vim.notify(string.format(
|
||||||
"java version check failed: exit code %s", out.code),
|
"java version check failed: exit code %s", out.code),
|
||||||
vim.log.levels.ERROR, { title = misc.appid })
|
vim.log.levels.ERROR, { title = core.misc.appid })
|
||||||
vim.notify(string.format(
|
vim.notify(string.format(
|
||||||
"%s", vim.inspect(out.stdout)),
|
"%s", vim.inspect(out.stdout)),
|
||||||
vim.log.levels.ERROR, { title = misc.appid })
|
vim.log.levels.ERROR, { title = core.misc.appid })
|
||||||
return false
|
return false
|
||||||
elseif not v then
|
elseif not v then
|
||||||
vim.notify("no java version info found", vim.log.levels.ERROR,
|
vim.notify("no java version info found", vim.log.levels.ERROR,
|
||||||
{ title = misc.appid })
|
{ title = core.misc.appid })
|
||||||
return false
|
return false
|
||||||
elseif v.major < 21 then
|
elseif v.major < 21 then
|
||||||
vim.notify(string.format(
|
vim.notify(string.format(
|
||||||
"java version %s < 21.0.0 Cannot run jdtls, bailing out",
|
"java version %s < 21.0.0 Cannot run jdtls, bailing out",
|
||||||
v[1].."."..v[2].."."..v[3]),
|
v[1].."."..v[2].."."..v[3]),
|
||||||
vim.log.levels.ERROR, { title = misc.appid })
|
vim.log.levels.ERROR, { title = core.misc.appid })
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local map_local = core.misc.map_local
|
||||||
local map_local = misc.map_local
|
|
||||||
|
|
||||||
map_local("n", "h", "-", { noremap = false, remap = true }) -- Go up a directory
|
map_local("n", "h", "-", { noremap = false, remap = true }) -- Go up a directory
|
||||||
map_local("n", "l", "<CR>", { noremap = false, remap = true }) -- Go down a directory / open a file
|
map_local("n", "l", "<CR>", { noremap = false, remap = true }) -- Go down a directory / open a file
|
||||||
@ -17,5 +16,5 @@ end)
|
|||||||
map_local("n", "rt", function()
|
map_local("n", "rt", function()
|
||||||
vim.api.nvim_set_current_dir(vim.b.netrw_curdir)
|
vim.api.nvim_set_current_dir(vim.b.netrw_curdir)
|
||||||
vim.notify("root dir updated: "..vim.b.netrw_curdir, vim.log.levels.LOW,
|
vim.notify("root dir updated: "..vim.b.netrw_curdir, vim.log.levels.LOW,
|
||||||
{ title = misc.appid })
|
{ title = core.misc.appid })
|
||||||
end)
|
end)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local map = require("core.misc").map
|
local map = core.misc.map
|
||||||
|
|
||||||
return {
|
return {
|
||||||
on_attach = function(_, bufnr)
|
on_attach = function(_, bufnr)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local map = require("core.misc").map
|
local map = core.misc.map
|
||||||
|
|
||||||
return {
|
return {
|
||||||
on_attach = function(_, bufnr)
|
on_attach = function(_, bufnr)
|
||||||
|
22
init.lua
22
init.lua
@ -1,10 +1,13 @@
|
|||||||
-- TODO: after switching to dep with lazy loading check out vim-startuptime
|
-- TODO: after switching to dep with lazy loading check out vim-startuptime
|
||||||
-- again
|
-- again
|
||||||
|
|
||||||
|
_G.core = require("core")
|
||||||
|
|
||||||
-- enable performance stuff
|
-- enable performance stuff
|
||||||
if vim.fn.has("nvim-0.9") == true then
|
vim.loader.enable()
|
||||||
vim.loader.enable()
|
|
||||||
end
|
-- load user config
|
||||||
|
require("conf")
|
||||||
|
|
||||||
-- bootstrap plugin manager
|
-- bootstrap plugin manager
|
||||||
local path = vim.fn.stdpath("data").."/site/pack/deps/opt/dep"
|
local path = vim.fn.stdpath("data").."/site/pack/deps/opt/dep"
|
||||||
@ -14,14 +17,6 @@ if vim.fn.empty(vim.fn.glob(path)) > 0 then
|
|||||||
end
|
end
|
||||||
vim.cmd("packadd dep")
|
vim.cmd("packadd dep")
|
||||||
|
|
||||||
-- load miscellaneous utilities
|
|
||||||
local misc = require("core.misc")
|
|
||||||
|
|
||||||
-- load user config
|
|
||||||
misc.include("conf.opts") -- setup options
|
|
||||||
misc.include("conf.binds") -- setup keybinds
|
|
||||||
misc.include("conf.autos") -- setup autos
|
|
||||||
|
|
||||||
-- load plugins
|
-- load plugins
|
||||||
require("dep") {
|
require("dep") {
|
||||||
{ "squibid/dep",
|
{ "squibid/dep",
|
||||||
@ -35,8 +30,9 @@ require("dep") {
|
|||||||
|
|
||||||
for _, file in ipairs(vim.api.nvim_get_runtime_file(
|
for _, file in ipairs(vim.api.nvim_get_runtime_file(
|
||||||
"lua/conf/plugins/*.lua", true)) do
|
"lua/conf/plugins/*.lua", true)) do
|
||||||
local ret = misc.include("conf.plugins."..file:gsub("^.*/",
|
local ret = require("conf.plugins."..file:gsub("^.*/", ""):gsub("%.lua$",
|
||||||
""):gsub("%.lua$", ""))
|
""))
|
||||||
|
|
||||||
if type(ret) ~= "boolean" then
|
if type(ret) ~= "boolean" then
|
||||||
plugs[#plugs + 1] = ret
|
plugs[#plugs + 1] = ret
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local auto, augroup = core.misc.auto, core.misc.augroup
|
||||||
local auto, augroup = misc.auto, misc.augroup
|
|
||||||
|
|
||||||
-- auto commands which interact with bufferes without modifying them
|
-- auto commands which interact with bufferes without modifying them
|
||||||
local bufcheck = augroup("bufcheck")
|
local bufcheck = augroup("bufcheck")
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local map = core.misc.map
|
||||||
local map = misc.map
|
|
||||||
|
|
||||||
-- vim binds
|
-- vim binds
|
||||||
vim.g.mapleader = " " -- set leader key
|
vim.g.mapleader = " " -- set leader key
|
||||||
@ -25,20 +24,20 @@ map("n", "<leader>x", function() -- execute order 111
|
|||||||
local perm = vim.fn.getfperm(fn)
|
local perm = vim.fn.getfperm(fn)
|
||||||
if string.match(perm, "x", 3) then
|
if string.match(perm, "x", 3) then
|
||||||
vim.notify("Removed executable flags", vim.log.levels.INFO, {
|
vim.notify("Removed executable flags", vim.log.levels.INFO, {
|
||||||
title = misc.appid
|
title = core.misc.appid
|
||||||
})
|
})
|
||||||
vim.fn.setfperm(fn, string.sub(fn, 1, 2).."-"..string.sub(fn, 4, 5).."-"
|
vim.fn.setfperm(fn, string.sub(fn, 1, 2).."-"..string.sub(fn, 4, 5).."-"
|
||||||
..string.sub(fn, 7, 8).."-")
|
..string.sub(fn, 7, 8).."-")
|
||||||
else
|
else
|
||||||
vim.notify("Add executable flags", vim.log.levels.INFO, {
|
vim.notify("Add executable flags", vim.log.levels.INFO, {
|
||||||
title = misc.appid
|
title = core.misc.appid
|
||||||
})
|
})
|
||||||
vim.fn.setfperm(fn, string.sub(fn, 1, 2).."x"..string.sub(fn, 4, 5).."x"
|
vim.fn.setfperm(fn, string.sub(fn, 1, 2).."x"..string.sub(fn, 4, 5).."x"
|
||||||
..string.sub(fn, 7, 8).."x")
|
..string.sub(fn, 7, 8).."x")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
vim.notify("File doesn't exist", vim.log.levels.INFO, {
|
vim.notify("File doesn't exist", vim.log.levels.INFO, {
|
||||||
title = misc.appid
|
title = core.misc.appid
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end, { desc = "toggle executable flag of the file" })
|
end, { desc = "toggle executable flag of the file" })
|
||||||
|
3
lua/conf/init.lua
Normal file
3
lua/conf/init.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
require("conf.opts") -- setup options
|
||||||
|
require("conf.binds") -- setup keybinds
|
||||||
|
require("conf.autos") -- setup autos
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local auto = core.misc.auto
|
||||||
local auto = misc.auto
|
|
||||||
|
|
||||||
-- color stuff
|
-- color stuff
|
||||||
if vim.fn.has("termguicolors") then
|
if vim.fn.has("termguicolors") then
|
||||||
@ -84,8 +83,7 @@ do -- folding
|
|||||||
vim.opt.foldenable = true
|
vim.opt.foldenable = true
|
||||||
vim.o.fillchars = "fold: "
|
vim.o.fillchars = "fold: "
|
||||||
|
|
||||||
_G.Fold_text = require("core.folding")
|
vim.opt.foldtext = "v:lua.core.folding()"
|
||||||
vim.opt.foldtext = "v:lua.Fold_text()"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- statusline
|
do -- statusline
|
||||||
|
@ -1,18 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local map = core.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 = {}
|
local keymap_restore = {}
|
||||||
--- make the default hover binding work for nvim-dap instead of lsp
|
--- make the default hover binding work for nvim-dap instead of lsp
|
||||||
@ -66,7 +52,9 @@ return { "mfussenegger/nvim-dap",
|
|||||||
name = "Launch file",
|
name = "Launch file",
|
||||||
type = "codelldb",
|
type = "codelldb",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
program = select_program,
|
program = function()
|
||||||
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd()..'/', 'file')
|
||||||
|
end,
|
||||||
|
|
||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
stopOnEntry = false
|
stopOnEntry = false
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local map = core.misc.map
|
||||||
local map = misc.map
|
|
||||||
|
|
||||||
return { "lewis6991/gitsigns.nvim",
|
return { "lewis6991/gitsigns.nvim",
|
||||||
disable = not vim.fn.has("nvim-0.9.0"),
|
disable = not vim.fn.has("nvim-0.9.0"),
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
local misc = require("core.misc")
|
-- TODO: might end up writing my own because I like harpoon, but I hate that it
|
||||||
local map = misc.map
|
-- doesn't work properly without being pinned to a specific commit
|
||||||
|
|
||||||
|
local map = core.misc.map
|
||||||
|
|
||||||
return { "ThePrimeagen/harpoon",
|
return { "ThePrimeagen/harpoon",
|
||||||
disable = not vim.fn.has("nvim-0.8.0"),
|
disable = not vim.fn.has("nvim-0.8.0"),
|
||||||
@ -14,7 +16,7 @@ return { "ThePrimeagen/harpoon",
|
|||||||
map("n", "<leader>a", function()
|
map("n", "<leader>a", function()
|
||||||
harpoon:list():add()
|
harpoon:list():add()
|
||||||
vim.notify("added "..vim.fn.expand("%:t").." to quickmarks",
|
vim.notify("added "..vim.fn.expand("%:t").." to quickmarks",
|
||||||
vim.log.levels.INFO, { title = misc.appid })
|
vim.log.levels.INFO, { title = core.misc.appid })
|
||||||
end, { desc = "add current file to quickmarks" })
|
end, { desc = "add current file to quickmarks" })
|
||||||
|
|
||||||
map("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
|
map("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
return { "mawkler/hml.nvim",
|
|
||||||
function()
|
|
||||||
require("hml").setup {}
|
|
||||||
end
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
return { "kawre/leetcode.nvim",
|
|
||||||
requires = {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
"MunifTanjim/nui.nvim",
|
|
||||||
"nvim-treesitter/nvim-treesitter"
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
-- because we"re using treesitter make sure to install the html parser
|
|
||||||
vim.cmd("TSUpdate html")
|
|
||||||
end,
|
|
||||||
function()
|
|
||||||
require("leetcode").setup {
|
|
||||||
lang = "java"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
}
|
|
@ -5,7 +5,7 @@ return { "neovim/nvim-lspconfig",
|
|||||||
"mason-org/mason-lspconfig.nvim"
|
"mason-org/mason-lspconfig.nvim"
|
||||||
},
|
},
|
||||||
function()
|
function()
|
||||||
require("core.lsp.functions").setup()
|
core.lsp.setup()
|
||||||
require("mason-lspconfig").setup {
|
require("mason-lspconfig").setup {
|
||||||
ensure_added = {
|
ensure_added = {
|
||||||
"clangd",
|
"clangd",
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local map, auto = core.misc.map, core.misc.auto
|
||||||
local map = misc.map
|
|
||||||
|
|
||||||
return { "L3MON4D3/LuaSnip",
|
return { "L3MON4D3/LuaSnip",
|
||||||
branch = "v2.4.0",
|
branch = "v2.4.0",
|
||||||
@ -55,14 +54,21 @@ return { "L3MON4D3/LuaSnip",
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- load all snippets from snippet directory
|
-- collect all snippets and add them when in the correct file type
|
||||||
for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua",
|
for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua",
|
||||||
true)) do
|
true)) do
|
||||||
local fn = file:gsub("^.*/", ""):gsub("%.lua$", "")
|
local fn = file:gsub("^.*/", ""):gsub("%.lua$", "")
|
||||||
local ret = misc.include("snippets."..fn)
|
|
||||||
if type(ret) ~= "boolean" then
|
auto("FileType", {
|
||||||
luasnip.add_snippets(fn, ret, { key = fn })
|
pattern = fn,
|
||||||
end
|
once = true,
|
||||||
|
callback = function()
|
||||||
|
local ret = require("snippets."..fn)
|
||||||
|
if type(ret) ~= "boolean" then
|
||||||
|
luasnip.add_snippets(fn, ret, { key = fn })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local map = core.misc.map
|
||||||
local map = misc.map
|
|
||||||
|
|
||||||
return { "danymat/neogen",
|
return { "danymat/neogen",
|
||||||
requires = {
|
requires = {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local map = core.misc.map
|
||||||
local map = misc.map
|
|
||||||
|
|
||||||
-- helper function to parse output
|
-- helper function to parse output
|
||||||
local function parse_output(proc)
|
local function parse_output(proc)
|
||||||
|
9
lua/conf/plugins/refactoring.lua
Normal file
9
lua/conf/plugins/refactoring.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
return { "ThePrimeagen/refactoring.nvim",
|
||||||
|
requires = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
"nvim-treesitter/nvim-treesitter"
|
||||||
|
},
|
||||||
|
function()
|
||||||
|
require('refactoring').setup {}
|
||||||
|
end
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local map = core.misc.map
|
||||||
local map = misc.map
|
|
||||||
|
|
||||||
--- get the root directory for telescope to search
|
--- get the root directory for telescope to search
|
||||||
---@return string the root directory
|
---@return string the root directory
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
-- TODO: gotta rewrite this cause it's actual dogshit, and I don't want to deal
|
||||||
|
-- with nerd fonts or folke anymore also add support for TODO(name):
|
||||||
|
|
||||||
return { "folke/todo-comments.nvim",
|
return { "folke/todo-comments.nvim",
|
||||||
requires = "nvim-lua/plenary.nvim",
|
requires = "nvim-lua/plenary.nvim",
|
||||||
disable = not vim.fn.has("nvim-0.8.0"),
|
disable = not vim.fn.has("nvim-0.8.0"),
|
||||||
|
10
lua/conf/plugins/treesitter-context.lua
Normal file
10
lua/conf/plugins/treesitter-context.lua
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
return { "nvim-treesitter/nvim-treesitter-context",
|
||||||
|
requires = "nvim-treesitter/nvim-treesitter",
|
||||||
|
function()
|
||||||
|
require("treesitter-context").setup {
|
||||||
|
max_lines = 2,
|
||||||
|
line_numbers = true,
|
||||||
|
trim_scope = 'inner'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
@ -1,12 +1,3 @@
|
|||||||
table.contains = function(self, string)
|
|
||||||
for _, v in pairs(self) do
|
|
||||||
if v == string then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
return { "nvim-treesitter/nvim-treesitter",
|
return { "nvim-treesitter/nvim-treesitter",
|
||||||
disable = not vim.fn.has("nvim-0.10.0"),
|
disable = not vim.fn.has("nvim-0.10.0"),
|
||||||
config = function()
|
config = function()
|
||||||
@ -47,8 +38,7 @@ return { "nvim-treesitter/nvim-treesitter",
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- disable in big files
|
-- disable in big files
|
||||||
-- TODO: update before nvim 1.0 when vim.loop is removed
|
local ok, stats = pcall(vim.uv.fs_stat,
|
||||||
local ok, stats = pcall(vim.loop.fs_stat,
|
|
||||||
vim.api.nvim_buf_get_name(buf))
|
vim.api.nvim_buf_get_name(buf))
|
||||||
if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then
|
if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then
|
||||||
return true
|
return true
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
local misc = require("core.misc")
|
local map = core.misc.map
|
||||||
local map = misc.map
|
|
||||||
|
|
||||||
return { "Wansmer/treesj",
|
return { "Wansmer/treesj",
|
||||||
disable = not vim.fn.has("nvim-0.9.0"),
|
disable = not vim.fn.has("nvim-0.9.0"),
|
||||||
requires = "nvim-treesitter/nvim-treesitter",
|
requires = "nvim-treesitter/nvim-treesitter",
|
||||||
function()
|
function()
|
||||||
require("treesj").setup {
|
require("treesj").setup {
|
||||||
use_default_keymaps = false,
|
use_default_keymaps = false
|
||||||
}
|
}
|
||||||
|
|
||||||
map("n", "<leader>j", require("treesj").toggle, { desc = "fold code" })
|
map("n", "<leader>j", require("treesj").toggle, { desc = "fold code" })
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local misc = require("core.misc")
|
local map = core.misc.map
|
||||||
local map = misc.map
|
|
||||||
|
|
||||||
return { "mbbill/undotree",
|
return { "mbbill/undotree",
|
||||||
function()
|
function()
|
||||||
|
26
lua/core/color.lua
Normal file
26
lua/core/color.lua
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
--- copy highlight group
|
||||||
|
---@param hlgroup string highlight group to copy
|
||||||
|
---@param namespace? number highlight space
|
||||||
|
---@return table
|
||||||
|
function M.copyhl(hlgroup, namespace)
|
||||||
|
namespace = namespace or 0
|
||||||
|
|
||||||
|
local ok, hl = pcall(vim.api.nvim_get_hl, namespace, {
|
||||||
|
name = hlgroup,
|
||||||
|
create = false
|
||||||
|
})
|
||||||
|
if not ok then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, key in pairs({ "foreground", "background", "special" }) do
|
||||||
|
if hl[key] then
|
||||||
|
hl[key] = string.format("#%06x", hl[key])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return hl
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
41
lua/core/init.lua
Normal file
41
lua/core/init.lua
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
-- inspired by (and partially yoinked from): github.com/gonstoll/dotfiles
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
misc = require("core.misc"),
|
||||||
|
folding = require("core.folding"),
|
||||||
|
lsp = require("core.lsp"),
|
||||||
|
color = require("core.color"),
|
||||||
|
snippets = vim.fs.joinpath(vim.fn.stdpath("config"), "lua/core/snippets.lua"),
|
||||||
|
}
|
||||||
|
|
||||||
|
--- check if the given table contains an item, and return the key value pair if
|
||||||
|
--- it does
|
||||||
|
---@param self table table
|
||||||
|
---@param item any item to find
|
||||||
|
---@return boolean, [any, any]? found true if found
|
||||||
|
table.contains = function(self, item)
|
||||||
|
for k, v in pairs(self) do
|
||||||
|
if v == item then
|
||||||
|
return true, { k, v }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
M.mason = {
|
||||||
|
--- Gets a path to a package in the Mason registry.
|
||||||
|
--- Prefer this to `get_package`, since the package might not always be
|
||||||
|
--- available yet and trigger errors.
|
||||||
|
---@param pkg string
|
||||||
|
---@param path? string
|
||||||
|
get_pkg_path = function(pkg, path)
|
||||||
|
pcall(require, "mason") -- make sure Mason is loaded. Will fail when generating docs
|
||||||
|
|
||||||
|
local root = vim.env.MASON or vim.fs.joinpath(vim.fn.stdpath("data"), "mason")
|
||||||
|
path = path or ""
|
||||||
|
return vim.fs.joinpath(root, "packages", pkg, path)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
84
lua/core/lsp.lua
Normal file
84
lua/core/lsp.lua
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
---@diagnostic disable: param-type-mismatch
|
||||||
|
|
||||||
|
local misc = require("core.misc")
|
||||||
|
local map, auto = misc.map, misc.auto
|
||||||
|
local popup_opts, hover_opts, signature_opts, list_opts, location_opts
|
||||||
|
|
||||||
|
-- TODO: find a way to make the qflist current item be the one closest to the
|
||||||
|
-- cursor whenever we open it
|
||||||
|
local function on_list(opts)
|
||||||
|
vim.fn.setqflist({}, "r", opts)
|
||||||
|
if #opts.items > 1 then
|
||||||
|
vim.cmd.copen()
|
||||||
|
end
|
||||||
|
vim.cmd(".cc! 1")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- disable the default keybinds (they're bad)
|
||||||
|
for _, bind in ipairs({ "grn", "gra", "gri", "grr" }) do
|
||||||
|
pcall(vim.keymap.del, "n", bind)
|
||||||
|
end
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
--- setup vim lsp options
|
||||||
|
function M.setup()
|
||||||
|
-- options for different lsp functions
|
||||||
|
popup_opts = { border = vim.g.border_style }
|
||||||
|
hover_opts = vim.tbl_deep_extend("force", popup_opts, {})
|
||||||
|
signature_opts = vim.tbl_deep_extend("force", popup_opts, {})
|
||||||
|
list_opts = { on_list = on_list }
|
||||||
|
location_opts = vim.tbl_deep_extend("force", list_opts, {})
|
||||||
|
|
||||||
|
-- confgiure lsp
|
||||||
|
vim.diagnostic.config {
|
||||||
|
virtual_text = false,
|
||||||
|
virtual_lines = {
|
||||||
|
current_line = true
|
||||||
|
},
|
||||||
|
update_in_insert = false,
|
||||||
|
underline = true,
|
||||||
|
severity_sort = true,
|
||||||
|
signs = {
|
||||||
|
text = {
|
||||||
|
[vim.diagnostic.severity.ERROR] = "x",
|
||||||
|
[vim.diagnostic.severity.WARN] = "!",
|
||||||
|
[vim.diagnostic.severity.INFO] = "i",
|
||||||
|
[vim.diagnostic.severity.HINT] = "h"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- set default capabilities and attach function
|
||||||
|
vim.lsp.config['*'] = {
|
||||||
|
capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
}
|
||||||
|
|
||||||
|
-- make my attach function always run
|
||||||
|
auto("LspAttach", {
|
||||||
|
callback = function(event)
|
||||||
|
local opts = { buffer = event.buf, nowait = true }
|
||||||
|
|
||||||
|
-- LSP actions
|
||||||
|
map("n", "K", function() vim.lsp.buf.hover(hover_opts) end, opts)
|
||||||
|
map("n", "gd", function() vim.lsp.buf.definition(location_opts) end, opts)
|
||||||
|
map("n", "gD", function() vim.lsp.buf.declaration(location_opts) end, opts)
|
||||||
|
map("n", "gi", function() vim.lsp.buf.implementation(location_opts) end, opts)
|
||||||
|
map("n", "gy", function() vim.lsp.buf.type_definition(location_opts) end, opts)
|
||||||
|
map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts)
|
||||||
|
map("n", "<S-Tab>", function() vim.lsp.buf.signature_help(signature_opts) end, opts)
|
||||||
|
map("n", { "<leader>r", "<F2>" }, vim.lsp.buf.rename, opts)
|
||||||
|
map("n", { "gA", "<F4>" }, vim.lsp.buf.code_action, opts)
|
||||||
|
|
||||||
|
-- Diagnostics
|
||||||
|
map("n", "[d", function()
|
||||||
|
vim.diagnostic.jump({ count = -1 })
|
||||||
|
end, opts)
|
||||||
|
map("n", "]d", function()
|
||||||
|
vim.diagnostic.jump({ count = 1 })
|
||||||
|
end, opts)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
@ -1,100 +0,0 @@
|
|||||||
local misc = require("core.misc")
|
|
||||||
local map, auto = misc.map, misc.auto
|
|
||||||
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
-- TODO: find a way to make the qflist current item be the one closest to the
|
|
||||||
-- cursor whenever we open it
|
|
||||||
local function on_list(opts)
|
|
||||||
vim.fn.setqflist({}, "r", opts)
|
|
||||||
if #opts.items > 1 then
|
|
||||||
vim.cmd.copen()
|
|
||||||
end
|
|
||||||
vim.cmd(".cc! 1")
|
|
||||||
end
|
|
||||||
|
|
||||||
---@type vim.lsp.util.open_floating_preview.Opts
|
|
||||||
local popup_opts = {
|
|
||||||
border = vim.g.border_style
|
|
||||||
}
|
|
||||||
---@type vim.lsp.buf.hover.Opts
|
|
||||||
---@diagnostic disable-next-line: assign-type-mismatch
|
|
||||||
local hover_opts = vim.tbl_deep_extend("force", popup_opts, {})
|
|
||||||
|
|
||||||
---@type vim.lsp.buf.signature_help.Opts
|
|
||||||
---@diagnostic disable-next-line: assign-type-mismatch
|
|
||||||
local signature_opts = vim.tbl_deep_extend("force", popup_opts, {})
|
|
||||||
|
|
||||||
---@type vim.lsp.ListOpts
|
|
||||||
local list_opts = {
|
|
||||||
on_list = on_list
|
|
||||||
}
|
|
||||||
|
|
||||||
---@type vim.lsp.LocationOpts
|
|
||||||
---@diagnostic disable-next-line: assign-type-mismatch
|
|
||||||
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
|
|
||||||
---@param bufnr number buffer number
|
|
||||||
local function attach(bufnr)
|
|
||||||
local opts = { buffer = bufnr, nowait = true }
|
|
||||||
|
|
||||||
-- LSP actions
|
|
||||||
map("n", "K", function() vim.lsp.buf.hover(hover_opts) end, opts)
|
|
||||||
map("n", "gd", function() vim.lsp.buf.definition(location_opts) end, opts)
|
|
||||||
map("n", "gD", function() vim.lsp.buf.declaration(location_opts) end, opts)
|
|
||||||
map("n", "gi", function() vim.lsp.buf.implementation(location_opts) end, opts)
|
|
||||||
map("n", "gy", function() vim.lsp.buf.type_definition(location_opts) end, opts)
|
|
||||||
map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts)
|
|
||||||
map("n", "<S-Tab>", function() vim.lsp.buf.signature_help(signature_opts) end, opts)
|
|
||||||
map("n", { "<leader>r", "<F2>" }, vim.lsp.buf.rename, opts)
|
|
||||||
map("n", { "gA", "<F4>" }, vim.lsp.buf.code_action, opts)
|
|
||||||
|
|
||||||
-- Diagnostics
|
|
||||||
map("n", "[d", function()
|
|
||||||
vim.diagnostic.jump({ count = -1 })
|
|
||||||
end, opts)
|
|
||||||
map("n", "]d", function()
|
|
||||||
vim.diagnostic.jump({ count = 1 })
|
|
||||||
end, opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- setup vim lsp options
|
|
||||||
function M.setup()
|
|
||||||
vim.diagnostic.config {
|
|
||||||
virtual_text = false,
|
|
||||||
virtual_lines = {
|
|
||||||
current_line = true
|
|
||||||
},
|
|
||||||
update_in_insert = false,
|
|
||||||
underline = true,
|
|
||||||
severity_sort = true,
|
|
||||||
signs = {
|
|
||||||
text = {
|
|
||||||
[vim.diagnostic.severity.ERROR] = "x",
|
|
||||||
[vim.diagnostic.severity.WARN] = "!",
|
|
||||||
[vim.diagnostic.severity.INFO] = "i",
|
|
||||||
[vim.diagnostic.severity.HINT] = "h"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-- set default capabilities and attach function
|
|
||||||
vim.lsp.config['*'] = {
|
|
||||||
capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
}
|
|
||||||
|
|
||||||
-- make my attach function always run
|
|
||||||
auto("LspAttach", {
|
|
||||||
callback = function(event)
|
|
||||||
attach(event.buf)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -3,18 +3,6 @@ local M = {}
|
|||||||
--- vim.notify title
|
--- vim.notify title
|
||||||
M.appid = "Nvim Config"
|
M.appid = "Nvim Config"
|
||||||
|
|
||||||
--- safe version of require
|
|
||||||
---@param fn string name of file to include
|
|
||||||
---@return any
|
|
||||||
function M.include(fn)
|
|
||||||
local ok, r = pcall(require, fn)
|
|
||||||
if not ok then
|
|
||||||
vim.notify("Could not find '"..fn.."': "..r, vim.log.levels.WARN, { title = M.appid })
|
|
||||||
return ok
|
|
||||||
end
|
|
||||||
return r
|
|
||||||
end
|
|
||||||
|
|
||||||
--- loop through files in directory
|
--- loop through files in directory
|
||||||
---@param path string absolute path of directory to be looped through
|
---@param path string absolute path of directory to be looped through
|
||||||
---@param body function function to use on every recursion of the loop
|
---@param body function function to use on every recursion of the loop
|
||||||
@ -99,29 +87,6 @@ function M.highlight(group, opts, namespace)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- copy highlight group
|
|
||||||
---@param hlgroup string highlight group to copy
|
|
||||||
---@param namespace? number highlight space
|
|
||||||
---@return table
|
|
||||||
function M.cpyhl(hlgroup, namespace)
|
|
||||||
namespace = namespace or 0
|
|
||||||
|
|
||||||
local ok, hl = pcall(vim.api.nvim_get_hl, namespace, {
|
|
||||||
name = hlgroup,
|
|
||||||
create = false
|
|
||||||
})
|
|
||||||
if not ok then
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, key in pairs({ "foreground", "background", "special" }) do
|
|
||||||
if hl[key] then
|
|
||||||
hl[key] = string.format("#%06x", hl[key])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return hl
|
|
||||||
end
|
|
||||||
|
|
||||||
--- highlight something with some highlight group for a certain amount of time
|
--- highlight something with some highlight group for a certain amount of time
|
||||||
--- example:
|
--- example:
|
||||||
--- ```lua
|
--- ```lua
|
||||||
|
@ -21,3 +21,7 @@ conds_expand = require("luasnip.extras.conditions.expand")
|
|||||||
ts_postfix = require("luasnip.extras.treesitter_postfix").treesitter_postfix
|
ts_postfix = require("luasnip.extras.treesitter_postfix").treesitter_postfix
|
||||||
postfix = require("luasnip.extras.postfix").postfix
|
postfix = require("luasnip.extras.postfix").postfix
|
||||||
ms = ls.multi_snippet
|
ms = ls.multi_snippet
|
||||||
|
|
||||||
|
function file_name(_, _, _)
|
||||||
|
return vim.fn.expand("%:t:r")
|
||||||
|
end
|
@ -1,3 +0,0 @@
|
|||||||
function file_name(_, _, _)
|
|
||||||
return vim.fn.expand("%:t:r")
|
|
||||||
end
|
|
@ -1,4 +1,4 @@
|
|||||||
require('core.snippets.shorthands')
|
dofile(core.snippets)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- function snippet
|
-- function snippet
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
require("core.snippets.shorthands")
|
dofile(core.snippets)
|
||||||
require("core.snippets.functions")
|
|
||||||
|
|
||||||
--- shortcut to choose between java access modifiers
|
--- shortcut to choose between java access modifiers
|
||||||
---@param idx number index of the node
|
---@param idx number index of the node
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
require("core.snippets.shorthands")
|
dofile(core.snippets)
|
||||||
require("core.snippets.functions")
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- header level 1, usually this has the same name as the file
|
-- header level 1, usually this has the same name as the file
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
require("core.snippets.shorthands")
|
dofile(core.snippets)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- translate snippet
|
-- translate snippet
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
require("core.snippets.shorthands")
|
dofile(core.snippets)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
s("php", {
|
s("php", {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
require("core.snippets.shorthands")
|
dofile(core.snippets)
|
||||||
require("core.snippets.functions")
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- document snippet
|
-- document snippet
|
||||||
|
Reference in New Issue
Block a user