Compare commits
14 Commits
62945314e2
...
master
Author | SHA1 | Date | |
---|---|---|---|
597de90d41
|
|||
47b0e795cd
|
|||
a96cb4bef7
|
|||
06a9c9e45d
|
|||
55f11ab1ba
|
|||
43b4369041
|
|||
baec11b559
|
|||
72d99537bf
|
|||
9c7c46855c
|
|||
86d7f17341
|
|||
869859a2ce
|
|||
33b35f16c1
|
|||
a7ac4e76ea
|
|||
b20f5d07a6
|
@@ -1,3 +1,4 @@
|
|||||||
|
-- TODO: find out why this doesn't work when java isn't the first filetype I open
|
||||||
local map, auto = core.misc.map, core.misc.auto
|
local map, auto = core.misc.map, core.misc.auto
|
||||||
|
|
||||||
local ok, jdtls = pcall(require, "jdtls")
|
local ok, jdtls = pcall(require, "jdtls")
|
||||||
@@ -12,7 +13,7 @@ local java_dap_install = core.mason.get_pkg_path("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 = {
|
||||||
"java", -- 💀
|
"/usr/lib/jvm/openjdk21/bin/java", -- 💀
|
||||||
"-jar",
|
"-jar",
|
||||||
vim.fn.glob(vim.fs.joinpath(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",
|
||||||
|
17
after/lsp/basedpyright.lua
Normal file
17
after/lsp/basedpyright.lua
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
return {
|
||||||
|
settings = {
|
||||||
|
python = {
|
||||||
|
pythonPath = "python"
|
||||||
|
},
|
||||||
|
basedpyright = {
|
||||||
|
reportAny = false,
|
||||||
|
analysis = {
|
||||||
|
autoSearchPaths = true,
|
||||||
|
diagnosticMode = "workspace",
|
||||||
|
inlayHints = {
|
||||||
|
callArgumentNames = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -30,4 +30,12 @@ auto("BufWritePre", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- FIXME: disable for now until I can do more work and make it work better
|
||||||
|
-- auto({ "BufEnter", "CursorMoved", "CursorMovedI" }, {
|
||||||
|
-- group = bufcheck,
|
||||||
|
-- callback = function()
|
||||||
|
-- core.color.todo_comments()
|
||||||
|
-- end
|
||||||
|
-- })
|
||||||
|
|
||||||
core.color.setup_termbg_sync()
|
core.color.setup_termbg_sync()
|
||||||
|
@@ -42,14 +42,25 @@ map("i", "<C-n>", function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end, { desc = "Trigger/select next completion" })
|
end, { desc = "Trigger/select next completion" })
|
||||||
|
map("i", "<CR>", function()
|
||||||
|
if vim.fn.pumvisible() ~= 0 then
|
||||||
|
feedkeys("<C-e><CR>")
|
||||||
|
else
|
||||||
|
feedkeys("<CR>")
|
||||||
|
end
|
||||||
|
end, { desc = "prevent omnifunc from completing on <CR>" })
|
||||||
map("i", "<C-s>", "<C-x><C-s>", { desc = "Trigger spell completion" })
|
map("i", "<C-s>", "<C-x><C-s>", { desc = "Trigger spell completion" })
|
||||||
map("n", "<C-s>", lz "<cmd>se spell<CR>ea<C-x><C-s><cmd>se nospell<CR>", { desc = "Trigger spell completion" })
|
map("n", "<C-s>", lz "<cmd>se spell<CR>ea<C-x><C-s><cmd>se nospell<CR>", { desc = "Trigger spell completion" })
|
||||||
|
|
||||||
-- quickfix
|
-- quickfix
|
||||||
map("n", "<M-j>", "<cmd>cnext<CR>", { desc = "qf next" })
|
map("n", "<M-j>", lz "<cmd>cnext<CR>zz", { desc = "qf next" })
|
||||||
map("n", "<M-k>", "<cmd>cprev<CR>", { desc = "qf prev" })
|
map("n", "<M-k>", lz "<cmd>cprev<CR>zz", { desc = "qf prev" })
|
||||||
map("n", "<M-c>", "<cmd>cclose<CR>", { desc = "qf close" })
|
map("n", "<M-c>", "<cmd>cclose<CR>", { desc = "qf close" })
|
||||||
map("n", "<M-x>", "<cmd>cope<CR>", { desc = "qf open" })
|
map("n", "<M-x>", lz(function()
|
||||||
|
local win = vim.api.nvim_get_current_win()
|
||||||
|
vim.cmd.cope()
|
||||||
|
vim.api.nvim_set_current_win(win)
|
||||||
|
end), { desc = "qf open" })
|
||||||
|
|
||||||
-- man pages
|
-- man pages
|
||||||
map("n", "<C-k>", "<cmd>Man<CR>")
|
map("n", "<C-k>", "<cmd>Man<CR>")
|
||||||
|
@@ -12,6 +12,7 @@ vim.o.cc = "80"
|
|||||||
|
|
||||||
-- indents + tabs
|
-- indents + tabs
|
||||||
local tabwidth = 2
|
local tabwidth = 2
|
||||||
|
vim.o.et = true
|
||||||
vim.o.ts = tabwidth
|
vim.o.ts = tabwidth
|
||||||
vim.o.sw = tabwidth
|
vim.o.sw = tabwidth
|
||||||
vim.o.sts = -1
|
vim.o.sts = -1
|
||||||
@@ -29,15 +30,18 @@ vim.o.udf = true
|
|||||||
-- searching
|
-- searching
|
||||||
vim.o.ic = true
|
vim.o.ic = true
|
||||||
|
|
||||||
-- make windows look nice
|
-- make windows look nice wrapped in pcall cause it's causing my setup to go
|
||||||
vim.o.winborder = "solid"
|
-- bezerk inside of git commit buffers
|
||||||
|
pcall(function() vim.o.winborder = '▄,▄,▄,█,▀,▀,▀,█' end)
|
||||||
|
|
||||||
-- wild menus
|
-- wild menus
|
||||||
vim.o.ph = 20
|
vim.o.ph = 20
|
||||||
vim.o.wic = true
|
vim.o.wic = true
|
||||||
vim.o.wop = "fuzzy,pum,tagfile"
|
vim.o.wop = "fuzzy,pum"
|
||||||
|
vim.o.wim = "noselect:lastused,full"
|
||||||
|
|
||||||
-- completion
|
-- completion
|
||||||
|
vim.o.cpt = ".,w,b,u,d,i"
|
||||||
vim.o.cot = "menu,menuone,noinsert,fuzzy,popup"
|
vim.o.cot = "menu,menuone,noinsert,fuzzy,popup"
|
||||||
vim.o.cia = "kind,abbr,menu"
|
vim.o.cia = "kind,abbr,menu"
|
||||||
-- waiting for https://github.com/neovim/neovim/pull/25541 to land
|
-- waiting for https://github.com/neovim/neovim/pull/25541 to land
|
||||||
@@ -77,7 +81,7 @@ do -- statusline
|
|||||||
"%r", -- readonly flag
|
"%r", -- readonly flag
|
||||||
"%=", -- seperate left and right side
|
"%=", -- seperate left and right side
|
||||||
|
|
||||||
-- print out the number of lsp clients attached with nice colors :)
|
-- print out the number of lsp clients attached
|
||||||
"λ"..#vim.lsp.get_clients({ bufnr = 0 }), " ",
|
"λ"..#vim.lsp.get_clients({ bufnr = 0 }), " ",
|
||||||
|
|
||||||
"%<", -- we can start truncating here (I want to keep the file name)
|
"%<", -- we can start truncating here (I want to keep the file name)
|
||||||
|
85
lua/conf/plugins/gitsigns.lua
Normal file
85
lua/conf/plugins/gitsigns.lua
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
local map = core.misc.map
|
||||||
|
|
||||||
|
return { "lewis6991/gitsigns.nvim",
|
||||||
|
lazy = function(load)
|
||||||
|
load:auto({ "BufEnter", "BufNew" }, {
|
||||||
|
callback = function()
|
||||||
|
local paths = vim.fs.find({ ".git", }, { upward = true })
|
||||||
|
if #paths > 0 then
|
||||||
|
load:cleanup()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
load:cmd("Gitsigns")
|
||||||
|
end,
|
||||||
|
load = function()
|
||||||
|
local gs = require("gitsigns")
|
||||||
|
|
||||||
|
gs.setup {
|
||||||
|
signs = {
|
||||||
|
add = { text = "│" },
|
||||||
|
change = { text = "│" },
|
||||||
|
delete = { text = "-" },
|
||||||
|
topdelete = { text = "‾" },
|
||||||
|
changedelete = { text = "~" },
|
||||||
|
untracked = { text = "┆" }
|
||||||
|
},
|
||||||
|
|
||||||
|
signcolumn = true,
|
||||||
|
numhl = false,
|
||||||
|
linehl = false,
|
||||||
|
word_diff = false,
|
||||||
|
|
||||||
|
watch_gitdir = {
|
||||||
|
interval = 1000,
|
||||||
|
follow_files = true
|
||||||
|
},
|
||||||
|
|
||||||
|
attach_to_untracked = true,
|
||||||
|
current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>",
|
||||||
|
|
||||||
|
preview_config = { border = vim.g.border_style },
|
||||||
|
|
||||||
|
on_attach = function(bufnr)
|
||||||
|
local opts = { buffer = bufnr }
|
||||||
|
|
||||||
|
-- Navigation
|
||||||
|
map("n", "]c", function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return "]c"
|
||||||
|
end
|
||||||
|
vim.schedule(function() gs.next_hunk() end)
|
||||||
|
end, { expr = true, buffer = bufnr })
|
||||||
|
|
||||||
|
map("n", "[c", function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return "[c"
|
||||||
|
end
|
||||||
|
vim.schedule(function() gs.prev_hunk() end)
|
||||||
|
end, { expr = true, buffer = bufnr })
|
||||||
|
|
||||||
|
-- Actions
|
||||||
|
map("n", "<leader>hs", gs.stage_hunk, opts)
|
||||||
|
map("n", "<leader>hr", gs.reset_hunk, opts)
|
||||||
|
map("v", "<leader>hs", function()
|
||||||
|
gs.stage_hunk { vim.fn.line("."), vim.fn.line("v") }
|
||||||
|
end, opts)
|
||||||
|
map("v", "<leader>hr", function()
|
||||||
|
gs.reset_hunk { vim.fn.line("."), vim.fn.line("v") }
|
||||||
|
end, opts)
|
||||||
|
map("n", "<leader>hS", gs.stage_buffer, opts)
|
||||||
|
map("n", "<leader>hu", gs.undo_stage_hunk, opts)
|
||||||
|
map("n", "<leader>hR", gs.reset_buffer, opts)
|
||||||
|
map("n", "<leader>hp", gs.preview_hunk, opts)
|
||||||
|
map("n", "<leader>hb", function() gs.blame_line { full = true } end, opts)
|
||||||
|
map("n", "<leader>tb", gs.toggle_current_line_blame, opts)
|
||||||
|
map("n", "<leader>hd", gs.diffthis, opts)
|
||||||
|
map("n", "<leader>hD", function() gs.diffthis("~") end, opts)
|
||||||
|
map("n", "<leader>td", gs.toggle_deleted, opts)
|
||||||
|
|
||||||
|
-- Text object
|
||||||
|
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", opts)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
@@ -1,8 +1,26 @@
|
|||||||
local nonels_augroup = core.misc.augroup("nullls formatting")
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
{ "neovim/nvim-lspconfig",
|
||||||
|
reqs = {
|
||||||
|
"mason-org/mason.nvim",
|
||||||
|
"mason-org/mason-lspconfig.nvim"
|
||||||
|
},
|
||||||
|
load = function()
|
||||||
|
core.lsp.setup()
|
||||||
|
require("mason-lspconfig").setup {
|
||||||
|
ensure_added = {
|
||||||
|
"clangd",
|
||||||
|
"mesonlsp",
|
||||||
|
"bashls",
|
||||||
|
"jdtls",
|
||||||
|
"lua_ls",
|
||||||
|
"basedpyright",
|
||||||
|
"debugpy"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
},
|
||||||
|
|
||||||
{ "mason-org/mason.nvim",
|
{ "mason-org/mason.nvim",
|
||||||
reqs = "neovim/nvim-lspconfig",
|
|
||||||
load = function()
|
load = function()
|
||||||
require("mason").setup {
|
require("mason").setup {
|
||||||
ui = {
|
ui = {
|
||||||
@@ -14,41 +32,10 @@ return {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
core.mason.ensure_installed()
|
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "mfussenegger/nvim-jdtls",
|
{ "mfussenegger/nvim-jdtls",
|
||||||
reqs = "mfussenegger/nvim-dap"
|
reqs = "mfussenegger/nvim-dap"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "nvimtools/none-ls.nvim",
|
|
||||||
lazy = dep_short.ft("python"),
|
|
||||||
load = function()
|
|
||||||
local null_ls = require("null-ls")
|
|
||||||
|
|
||||||
null_ls.setup {
|
|
||||||
sources = {
|
|
||||||
null_ls.builtins.formatting.black
|
|
||||||
},
|
|
||||||
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
if client:supports_method("textDocument/formatting") then
|
|
||||||
vim.api.nvim_clear_autocmds({
|
|
||||||
group = nonels_augroup,
|
|
||||||
buffer = bufnr
|
|
||||||
})
|
|
||||||
core.misc.auto("BufWritePre", {
|
|
||||||
group = nonels_augroup,
|
|
||||||
buffer = bufnr,
|
|
||||||
callback = function()
|
|
||||||
vim.lsp.buf.format({ bufnr = bufnr })
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ return { "mellow-theme/mellow.nvim",
|
|||||||
|
|
||||||
-- make floats darker
|
-- make floats darker
|
||||||
["NormalFloat"] = { fg = c.fg, bg = "#111111" },
|
["NormalFloat"] = { fg = c.fg, bg = "#111111" },
|
||||||
["FloatBorder"] = { link = "NormalFloat" },
|
["FloatBorder"] = { fg = "#111111" },
|
||||||
|
|
||||||
-- Make pmenu look good
|
-- Make pmenu look good
|
||||||
["Pmenu"] = { link = "NormalFloat" },
|
["Pmenu"] = { link = "NormalFloat" },
|
||||||
@@ -39,12 +39,23 @@ return { "mellow-theme/mellow.nvim",
|
|||||||
-- telescope styling so I can see when coding outside (real)
|
-- telescope styling so I can see when coding outside (real)
|
||||||
["TelescopeResultsNormal"] = { bg = c.bg_dark },
|
["TelescopeResultsNormal"] = { bg = c.bg_dark },
|
||||||
["TelescopeResultsBorder"] = { link = "TelescopeResultsNormal" },
|
["TelescopeResultsBorder"] = { link = "TelescopeResultsNormal" },
|
||||||
["TelescopeResultsTitle"] = {
|
["TelescopeResultsTitle"] = { bg = c.bg, fg = c.bg },
|
||||||
bg = core.color.copyhl("TelescopeResultsNormal").background,
|
|
||||||
fg = core.color.copyhl("TelescopeResultsNormal").background
|
|
||||||
},
|
|
||||||
["TelescopePreviewNormal"] = { link = "NormalFloat" },
|
["TelescopePreviewNormal"] = { link = "NormalFloat" },
|
||||||
["TelescopePreviewBorder"] = { link = "TelescopePreviewNormal" }
|
["TelescopePreviewBorder"] = { link = "TelescopePreviewNormal" },
|
||||||
|
|
||||||
|
-- add highlight groups for my todo highlighting
|
||||||
|
["TodoTODO"] = { link = "DiagnosticHint" },
|
||||||
|
["TodoTODOBG"] = { fg = c.bg, bg = c.cyan, bold = true },
|
||||||
|
["TodoTODOSIGN"] = { fg = c.cyan, bg = c.cyan, bold = true },
|
||||||
|
["TodoBUG"] = { link = "DiagnosticError" },
|
||||||
|
["TodoBUGBG"] = { fg = c.bg, bg = c.red, bold = true },
|
||||||
|
["TodoBUGSIGN"] = { fg = c.red, bg = c.red, bold = true },
|
||||||
|
["TodoTEST"] = { link = "DiagnosticInfo" },
|
||||||
|
["TodoTESTBG"] = { fg = c.bg, bg = c.blue, bold = true },
|
||||||
|
["TodoTESTSIGN"] = { fg = c.blue, bg = c.blue, bold = true },
|
||||||
|
["TodoWARN"] = { link = "DiagnosticWarn" },
|
||||||
|
["TodoWARNBG"] = { fg = c.bg, bg = c.yellow, bold = true },
|
||||||
|
["TodoWARNSIGN"] = { fg = c.yellow, bg = c.yellow, bold = true },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,12 +1,5 @@
|
|||||||
local map = core.misc.map
|
local map = core.misc.map
|
||||||
|
|
||||||
local permission_hlgroups = {
|
|
||||||
["-"] = "NonText",
|
|
||||||
["r"] = "DiagnosticSignWarn",
|
|
||||||
["w"] = "DiagnosticSignHint",
|
|
||||||
["x"] = "DiagnosticSignOk",
|
|
||||||
}
|
|
||||||
|
|
||||||
return { "stevearc/oil.nvim",
|
return { "stevearc/oil.nvim",
|
||||||
lazy = dep_short.keymap("n", "-"),
|
lazy = dep_short.keymap("n", "-"),
|
||||||
load = function()
|
load = function()
|
||||||
@@ -20,7 +13,12 @@ return { "stevearc/oil.nvim",
|
|||||||
local hls = {}
|
local hls = {}
|
||||||
for i = 1, #permission_str do
|
for i = 1, #permission_str do
|
||||||
local char = permission_str:sub(i, i)
|
local char = permission_str:sub(i, i)
|
||||||
table.insert(hls, { permission_hlgroups[char], i - 1, i })
|
table.insert(hls, { ({
|
||||||
|
["-"] = "NonText",
|
||||||
|
["r"] = "DiagnosticSignWarn",
|
||||||
|
["w"] = "DiagnosticSignHint",
|
||||||
|
["x"] = "DiagnosticSignOk"
|
||||||
|
})[char], i - 1, i })
|
||||||
end
|
end
|
||||||
return hls
|
return hls
|
||||||
end,
|
end,
|
||||||
@@ -29,10 +27,10 @@ return { "stevearc/oil.nvim",
|
|||||||
},
|
},
|
||||||
|
|
||||||
-- fix the damn border
|
-- fix the damn border
|
||||||
confirmation = { border = vim.o.winborder },
|
confirmation = { winborder = vim.o.winborder },
|
||||||
progress = { border = vim.o.winborder },
|
progress = { winborder = vim.o.winborder },
|
||||||
ssh = { border = vim.o.winborder },
|
ssh = { winborder = vim.o.winborder },
|
||||||
keymaps_help = { border = vim.o.winborder }
|
keymaps_help = { winborder = vim.o.winborder }
|
||||||
}
|
}
|
||||||
|
|
||||||
map("n", "-", "<cmd>Oil<CR>")
|
map("n", "-", "<cmd>Oil<CR>")
|
||||||
|
10
lua/conf/plugins/opencode.lua
Normal file
10
lua/conf/plugins/opencode.lua
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
return { "NickvanDyke/opencode.nvim",
|
||||||
|
load = function()
|
||||||
|
core.misc.map("n", "<leader>oa", function()
|
||||||
|
require("opencode").ask()
|
||||||
|
end, { desc = "Ask opencode" })
|
||||||
|
core.misc.map("v", "<leader>oa", function()
|
||||||
|
require("opencode").ask("@selection: ")
|
||||||
|
end, { desc = "Ask opencode about selection" })
|
||||||
|
end
|
||||||
|
}
|
@@ -36,6 +36,7 @@ return { "nvim-telescope/telescope.nvim",
|
|||||||
load:keymap("n", "<leader>f")
|
load:keymap("n", "<leader>f")
|
||||||
load:keymap("n", "<leader>s")
|
load:keymap("n", "<leader>s")
|
||||||
load:keymap("n", "<leader>i")
|
load:keymap("n", "<leader>i")
|
||||||
|
load:keymap("n", "<leader>;")
|
||||||
load:keymap("n", "<leader>tc")
|
load:keymap("n", "<leader>tc")
|
||||||
load:keymap("n", "<leader>tp")
|
load:keymap("n", "<leader>tp")
|
||||||
end,
|
end,
|
||||||
@@ -141,6 +142,7 @@ return { "nvim-telescope/telescope.nvim",
|
|||||||
desc = "Find strings."
|
desc = "Find strings."
|
||||||
})
|
})
|
||||||
map("n", "<leader>i", telebuilt.help_tags, { desc = "find help tags." })
|
map("n", "<leader>i", telebuilt.help_tags, { desc = "find help tags." })
|
||||||
|
map("n", "<leader>;", telebuilt.lsp_document_symbols, { desc = "find doc symbols." })
|
||||||
|
|
||||||
-- find over specific directories
|
-- find over specific directories
|
||||||
map("n", "<leader>tc", function()
|
map("n", "<leader>tc", function()
|
||||||
|
@@ -48,6 +48,12 @@ return {
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.misc.map("n", "<leader><leader>t", function()
|
||||||
|
pcall(vim.cmd.TSInstall, vim.api.nvim_get_option_value("ft", {
|
||||||
|
buf = vim.api.nvim_get_current_buf()
|
||||||
|
}))
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -6,19 +6,19 @@ local M = {}
|
|||||||
---@return table
|
---@return table
|
||||||
function M.copyhl(hlgroup, namespace)
|
function M.copyhl(hlgroup, namespace)
|
||||||
namespace = namespace or 0
|
namespace = namespace or 0
|
||||||
local res = {}
|
local res = {
|
||||||
|
["foreground"] = "#ff0000",
|
||||||
|
["background"] = "#ff0000",
|
||||||
|
["special"] = "#ff0000"
|
||||||
|
}
|
||||||
|
|
||||||
local ok, hl = pcall(vim.api.nvim_get_hl, namespace, {
|
local ok, hl = pcall(vim.api.nvim_get_hl, namespace, {
|
||||||
name = hlgroup,
|
name = hlgroup,
|
||||||
create = false
|
create = false
|
||||||
})
|
})
|
||||||
if not ok then
|
if not ok then
|
||||||
-- return default
|
-- return error colors
|
||||||
return {
|
return res
|
||||||
["foreground"] = "#000000",
|
|
||||||
["background"] = "#000000",
|
|
||||||
["special"] = "#000000"
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, key in pairs({ "foreground", "background", "special" }) do
|
for _, key in pairs({ "foreground", "background", "special" }) do
|
||||||
@@ -29,6 +29,136 @@ function M.copyhl(hlgroup, namespace)
|
|||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local todo_comments_conf = {
|
||||||
|
TODO = {
|
||||||
|
-- TODO:
|
||||||
|
-- NOTE:
|
||||||
|
-- INFO:
|
||||||
|
"TODO", "NOTE", "INFO",
|
||||||
|
hlgroup = "TodoTODO"
|
||||||
|
},
|
||||||
|
BUG = {
|
||||||
|
-- BUG:
|
||||||
|
-- FIXME:
|
||||||
|
"BUG", "FIXME",
|
||||||
|
hlgroup = "TodoBUG"
|
||||||
|
},
|
||||||
|
TEST = {
|
||||||
|
-- TEST:
|
||||||
|
-- PERF:
|
||||||
|
"TEST", "PERF",
|
||||||
|
hlgroup = "TodoTEST"
|
||||||
|
},
|
||||||
|
WARN = {
|
||||||
|
-- WARN:
|
||||||
|
-- HACK:
|
||||||
|
"WARN", "HACK",
|
||||||
|
hlgroup = "TodoWARN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local todo_hl_ns = vim.api.nvim_create_namespace("todo_highlights")
|
||||||
|
|
||||||
|
--- highlight todo comments in the current buffer.
|
||||||
|
--- No I won't use folke's super bloated plugin.
|
||||||
|
---
|
||||||
|
--- TODO: make this work with coniguious comment blocks like this one.
|
||||||
|
--- currently this line won't be highlighted, but I'd like it to be
|
||||||
|
---
|
||||||
|
--- TEST: We could make this a plugin called ts-todo-hl or smthn like that, but
|
||||||
|
--- I'd be willing to bet no one would use it cause everyone loves folke too
|
||||||
|
--- much
|
||||||
|
function M.todo_comments()
|
||||||
|
local bufnr = vim.api.nvim_win_get_buf(0)
|
||||||
|
local ok, parser = pcall(vim.treesitter.get_parser, bufnr)
|
||||||
|
if not ok or not parser then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Construct the query for comments.
|
||||||
|
-- We're using treesitter so that I don't have to use external tooling.
|
||||||
|
local ok, comment_query = pcall(vim.treesitter.query.parse,
|
||||||
|
parser:lang(),
|
||||||
|
"(comment) @comment"
|
||||||
|
)
|
||||||
|
if not ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
parser:parse(false, function(err, trees)
|
||||||
|
if err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local root = trees[1]:root()
|
||||||
|
for _, match in comment_query:iter_matches(root, bufnr, 0, -1) do
|
||||||
|
for _, nodes in pairs(match) do
|
||||||
|
for _, node in ipairs(nodes) do
|
||||||
|
if not node or node:type() ~= "comment" then
|
||||||
|
goto continue
|
||||||
|
end
|
||||||
|
local text = vim.treesitter.get_node_text(node, bufnr)
|
||||||
|
-- TODO: instead of doing everything relative to the node we at this
|
||||||
|
-- point should obtain the node start and use a for loop to iterate
|
||||||
|
-- over the lines until we're no longer in a comment. This should
|
||||||
|
-- make dealing with comment blocks easier, and working with these
|
||||||
|
-- multiline comments easier.
|
||||||
|
for _, type in pairs(todo_comments_conf) do
|
||||||
|
for _, v in ipairs(type) do
|
||||||
|
local s, e = string.find(text, v..":")
|
||||||
|
if not s or not e then
|
||||||
|
s, e = string.find(text, v.."%b():")
|
||||||
|
end
|
||||||
|
if s and e then
|
||||||
|
local s_row, s_col = node:start()
|
||||||
|
local e_row, e_col = node:end_()
|
||||||
|
|
||||||
|
-- ensure that our string indicies are relative to the line
|
||||||
|
s = s + s_col
|
||||||
|
e = e + s_col
|
||||||
|
|
||||||
|
ok, err = pcall(vim.api.nvim_buf_set_extmark, bufnr, todo_hl_ns, s_row, e, {
|
||||||
|
hl_mode = "replace",
|
||||||
|
hl_group = type.hlgroup,
|
||||||
|
end_col = e_col,
|
||||||
|
end_row = e_row
|
||||||
|
})
|
||||||
|
if not ok then
|
||||||
|
print("fg", s_row, e, e_col, e_row)
|
||||||
|
print("fg", err)
|
||||||
|
end
|
||||||
|
|
||||||
|
ok, err = pcall(vim.api.nvim_buf_set_extmark, bufnr, todo_hl_ns, s_row, s - 2, {
|
||||||
|
hl_mode = "replace",
|
||||||
|
hl_group = type.hlgroup.."BG",
|
||||||
|
end_col = e - 1,
|
||||||
|
end_row = s_row
|
||||||
|
})
|
||||||
|
if not ok then
|
||||||
|
print("bg", s_row, s - 2, e - 1, s_row)
|
||||||
|
print("bg", err)
|
||||||
|
end
|
||||||
|
|
||||||
|
ok, err = pcall(vim.api.nvim_buf_set_extmark, bufnr, todo_hl_ns, s_row, e - 1, {
|
||||||
|
hl_mode = "replace",
|
||||||
|
hl_group = type.hlgroup.."SIGN",
|
||||||
|
end_col = e,
|
||||||
|
end_row = s_row
|
||||||
|
})
|
||||||
|
if not ok then
|
||||||
|
print("sn", s_row, e - 1, e, s_row)
|
||||||
|
print("sn", err)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
::continue::
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
-- Source: 'runtime/lua/vim/_defaults.lua' in Neovim source
|
-- Source: 'runtime/lua/vim/_defaults.lua' in Neovim source
|
||||||
local function parse_osc11(x)
|
local function parse_osc11(x)
|
||||||
local r, g, b = x:match('^\027%]11;rgb:(%x+)/(%x+)/(%x+)$')
|
local r, g, b = x:match('^\027%]11;rgb:(%x+)/(%x+)/(%x+)$')
|
||||||
|
@@ -35,45 +35,6 @@ local M = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
M.mason = {
|
M.mason = {
|
||||||
packages = {
|
|
||||||
formatters = { "black" },
|
|
||||||
daps = { "debugpy" },
|
|
||||||
lsps = {
|
|
||||||
"clangd",
|
|
||||||
"mesonlsp",
|
|
||||||
"bashls",
|
|
||||||
"lua_ls",
|
|
||||||
"jdtls",
|
|
||||||
"basedpyright"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
--- Attempt to install all desired packages. This only really works on first
|
|
||||||
--- install as mason seems to not remove the paths of the things we uninstall
|
|
||||||
--- and instead just removes the code, leaving behind it's metadata.
|
|
||||||
ensure_installed = function()
|
|
||||||
local to_install = {}
|
|
||||||
|
|
||||||
for _, type in pairs(M.mason.packages) do
|
|
||||||
for _, pkg in ipairs(type) do
|
|
||||||
-- HACK: some servers don't have the same name in mason as they do in
|
|
||||||
-- the vim lsp, we use the vim lsp names, and therefore need to
|
|
||||||
-- convert them in here when they're incorrect for mason
|
|
||||||
if pkg == "bashls" then pkg = "bash-language-server"
|
|
||||||
elseif pkg == "lua_ls" then pkg = "lua-language-server"
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.fn.isdirectory(M.mason.get_pkg_path(pkg)) == 0 then
|
|
||||||
table.insert(to_install, pkg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if #to_install > 0 then
|
|
||||||
vim.cmd.MasonInstall(to_install)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
--- Gets a path to a package in the Mason registry.
|
--- Gets a path to a package in the Mason registry.
|
||||||
--- Prefer this to `get_package`, since the package might not always be
|
--- Prefer this to `get_package`, since the package might not always be
|
||||||
--- available yet and trigger errors.
|
--- available yet and trigger errors.
|
||||||
|
@@ -8,6 +8,8 @@ local function on_list(opts)
|
|||||||
|
|
||||||
-- get to the closest reference to the cursor (likely the one gr or gd was
|
-- get to the closest reference to the cursor (likely the one gr or gd was
|
||||||
-- called on)
|
-- called on)
|
||||||
|
--
|
||||||
|
-- TODO: switch this to use opts.idx?
|
||||||
local closest, distance = 1, false
|
local closest, distance = 1, false
|
||||||
for i, item in ipairs(opts.items) do
|
for i, item in ipairs(opts.items) do
|
||||||
if item.filename and vim.fn.expand("%:p") == item.filename then
|
if item.filename and vim.fn.expand("%:p") == item.filename then
|
||||||
|
@@ -94,6 +94,19 @@ auto("CompleteDonePre", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO: we need to truncate the item.label to ensure that we don't
|
||||||
|
-- duplicate any text below is my attempt to start work on it:
|
||||||
|
--
|
||||||
|
-- local cursor = vim.api.nvim_win_get_cursor(0)
|
||||||
|
-- local line = vim.api.nvim_buf_get_lines(
|
||||||
|
-- vim.api.nvim_win_get_buf(0),
|
||||||
|
-- cursor[1] - 1,
|
||||||
|
-- cursor[1],
|
||||||
|
-- false
|
||||||
|
-- )[1]
|
||||||
|
-- item.label = string.gsub(item.label, string.sub(line, cursor[2] + 1), "")
|
||||||
|
-- item.insertText = item.label
|
||||||
|
|
||||||
-- if the item isn't a snippet then we might want to create a snippet
|
-- if the item isn't a snippet then we might want to create a snippet
|
||||||
if item.label and item.kind and item.insertTextFormat then
|
if item.label and item.kind and item.insertTextFormat then
|
||||||
if item.insertTextFormat ~= 2 and item.kind == 3 then
|
if item.insertTextFormat ~= 2 and item.kind == 3 then
|
||||||
|
@@ -2,9 +2,6 @@ local M = {}
|
|||||||
|
|
||||||
--- setup vim lsp options
|
--- setup vim lsp options
|
||||||
function M.setup()
|
function M.setup()
|
||||||
-- ensure the severs are setup
|
|
||||||
require("core.lsp.servers")
|
|
||||||
|
|
||||||
-- confgiure lsp
|
-- confgiure lsp
|
||||||
vim.diagnostic.config {
|
vim.diagnostic.config {
|
||||||
virtual_lines = {
|
virtual_lines = {
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
local servers = require("core").mason.packages.lsps
|
|
||||||
|
|
||||||
-- enable the servers I want
|
|
||||||
for _, server in ipairs(servers) do
|
|
||||||
-- skip jdtls, we start this on our own
|
|
||||||
if servers == "jdtls" then
|
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
vim.lsp.enable(server)
|
|
||||||
::continue::
|
|
||||||
end
|
|
@@ -16,14 +16,22 @@ auto('LspAttach', {
|
|||||||
-- highlight color codes via lsp (supported by cssls)
|
-- highlight color codes via lsp (supported by cssls)
|
||||||
-- #ff0000
|
-- #ff0000
|
||||||
if client:supports_method('textDocument/documentColor') then
|
if client:supports_method('textDocument/documentColor') then
|
||||||
vim.lsp.document_color.enable(true, ctx.buf)
|
pcall(vim.lsp.document_color.enable, true, ctx.buf)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- enable linked editing this allows lsps to modify things like html tags
|
-- enable linked editing this allows lsps to modify things like html tags
|
||||||
-- for example when you change <p> to <a> </p> will be changed by the lsp
|
-- for example when you change <p> to <a> </p> will be changed by the lsp
|
||||||
-- to </a>
|
-- to </a>
|
||||||
if client:supports_method('textDocument/linkedEditingRange') then
|
if client:supports_method('textDocument/linkedEditingRange') then
|
||||||
vim.lsp.linked_editing_range.enable(true, { client_id = client.id })
|
pcall(vim.lsp.linked_editing_range.enable, true, { client_id = client.id })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- disabled for now cause I don't like it
|
||||||
|
-- -- enable type formatting which allows lsps to modify text while you're
|
||||||
|
-- -- typing for example if you insert {} in a string in python basedpyright
|
||||||
|
-- -- will change the string to a format string
|
||||||
|
-- if client:supports_method('textDocument/onTypeFormatting') then
|
||||||
|
-- pcall(vim.lsp.on_type_formatting.enable, true, { client_id = client.id })
|
||||||
|
-- end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@@ -52,11 +52,22 @@ end
|
|||||||
|
|
||||||
--- Make an action lazy. This is mostly useful for keybinds which do a lot and
|
--- Make an action lazy. This is mostly useful for keybinds which do a lot and
|
||||||
--- you want to make sure the screen doesn't flash
|
--- you want to make sure the screen doesn't flash
|
||||||
---@param txt string the action
|
---@param txt string|function the action
|
||||||
---@return string lazified
|
---@return string|function lazified
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
function M.lz(txt)
|
function M.lz(txt)
|
||||||
return "<cmd>se lz<CR>"..txt.."<cmd>se lz!<CR>"
|
if type(txt) == "string" then
|
||||||
|
return "<cmd>se lz<CR>"..txt.."<cmd>se lz!<CR>"
|
||||||
|
elseif type(txt) == "function" then
|
||||||
|
return function()
|
||||||
|
vim.cmd.se("lz")
|
||||||
|
-- gotta make sure we can always unset lz
|
||||||
|
pcall(txt)
|
||||||
|
vim.cmd.se("lz!")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return txt
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
Reference in New Issue
Block a user