not quite sure what I've done here
This commit is contained in:
parent
b22873f45f
commit
83aaa5aef3
18 changed files with 392 additions and 392 deletions
|
|
@ -13,7 +13,7 @@ local java_dap_install = core.mason.get_pkg_path("java-debug-adapter")
|
|||
-- make sure to check if things with 💀 need updating
|
||||
local config = {
|
||||
cmd = {
|
||||
"/usr/lib/jvm/openjdk21/bin/java", -- 💀
|
||||
"java", -- 💀
|
||||
"-jar",
|
||||
vim.fn.glob(vim.fs.joinpath(jdtls_install, "plugins/org.eclipse.equinox.launcher_*.jar")),
|
||||
"-configuration", jdtls_install.."config_linux",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ return {
|
|||
checkThirdParty = "ApplyInMemory",
|
||||
library = {
|
||||
vim.env.VIMRUNTIME,
|
||||
"${3rd}/luv/library"
|
||||
"${3rd}/luv/library"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ auto("BufWritePre", {
|
|||
})
|
||||
|
||||
auto({ "BufEnter", "CursorMoved", "CursorMovedI" }, {
|
||||
group = bufcheck,
|
||||
callback = function()
|
||||
core.todo.todo_comments()
|
||||
end
|
||||
group = bufcheck,
|
||||
callback = function()
|
||||
core.todo.todo_comments()
|
||||
end
|
||||
})
|
||||
|
||||
core.color.setup_termbg_sync()
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ local map, lz = core.misc.map, core.misc.lz
|
|||
--- feed keys as userinput
|
||||
---@param keys string keys
|
||||
local function feedkeys(keys)
|
||||
vim.api.nvim_feedkeys(
|
||||
vim.api.nvim_replace_termcodes(keys, true, false, true),
|
||||
"n", true)
|
||||
vim.api.nvim_feedkeys(
|
||||
vim.api.nvim_replace_termcodes(keys, true, false, true),
|
||||
"n", true)
|
||||
end
|
||||
|
||||
-- vim binds
|
||||
|
|
@ -27,27 +27,27 @@ map("n", "<C-i>", lz "<C-i>zz")
|
|||
-- trigger completion menu
|
||||
-- (stolen from https://gist.github.com/MariaSolOs/2e44a86f569323c478e5a078d0cf98cc)
|
||||
map("i", "<C-n>", function()
|
||||
-- if the completion menu is already visible just go to the next item
|
||||
if vim.fn.pumvisible() ~= 0 then
|
||||
feedkeys("<C-n>")
|
||||
else
|
||||
if #vim.lsp.get_clients({ bufnr = 0 }) > 0 then
|
||||
vim.lsp.completion.get()
|
||||
else
|
||||
if vim.bo.omnifunc == "" then
|
||||
feedkeys("<C-x><C-n>")
|
||||
else
|
||||
feedkeys("<C-x><C-o>")
|
||||
end
|
||||
end
|
||||
end
|
||||
-- if the completion menu is already visible just go to the next item
|
||||
if vim.fn.pumvisible() ~= 0 then
|
||||
feedkeys("<C-n>")
|
||||
else
|
||||
if #vim.lsp.get_clients({ bufnr = 0 }) > 0 then
|
||||
vim.lsp.completion.get()
|
||||
else
|
||||
if vim.bo.omnifunc == "" then
|
||||
feedkeys("<C-x><C-n>")
|
||||
else
|
||||
feedkeys("<C-x><C-o>")
|
||||
end
|
||||
end
|
||||
end
|
||||
end, { desc = "Trigger/select next completion" })
|
||||
map("i", "<CR>", function()
|
||||
if vim.fn.pumvisible() ~= 0 then
|
||||
feedkeys("<C-e><CR>")
|
||||
else
|
||||
feedkeys("<CR>")
|
||||
end
|
||||
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("n", "<C-s>", lz "<cmd>se spell<CR>ea<C-x><C-s><cmd>se nospell<CR>", { desc = "Trigger spell completion" })
|
||||
|
|
@ -57,9 +57,9 @@ map("n", "<M-j>", lz "<cmd>cnext<CR>zz", { desc = "qf next" })
|
|||
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-x>", lz(function()
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
vim.cmd.cope()
|
||||
vim.api.nvim_set_current_win(win)
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
vim.cmd.cope()
|
||||
vim.api.nvim_set_current_win(win)
|
||||
end), { desc = "qf open" })
|
||||
|
||||
-- man pages
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ return {
|
|||
load = function()
|
||||
require("mason").setup {
|
||||
ui = {
|
||||
-- not sure why these are nerdfont icons by default
|
||||
-- not sure why these are nerdfont icons by default
|
||||
icons = {
|
||||
package_installed = "+",
|
||||
package_pending = "?",
|
||||
|
|
|
|||
|
|
@ -1,49 +1,49 @@
|
|||
local map = core.misc.map
|
||||
|
||||
return { "L3MON4D3/LuaSnip",
|
||||
branch = "v2.*",
|
||||
config = function()
|
||||
vim.cmd("make install_jsregexp")
|
||||
end,
|
||||
lazy = function(load)
|
||||
load:keymap({"i", "s"}, "<c-a>")
|
||||
load:keymap({"i", "s"}, "<c-e>")
|
||||
load:keymap({"i", "s"}, "<c-j>")
|
||||
load:keymap({"i", "s"}, "<c-k>")
|
||||
load:auto("InsertEnter")
|
||||
end,
|
||||
load = function()
|
||||
local ls = require("luasnip")
|
||||
branch = "v2.*",
|
||||
config = function()
|
||||
vim.cmd("make install_jsregexp")
|
||||
end,
|
||||
lazy = function(load)
|
||||
load:keymap({"i", "s"}, "<c-a>")
|
||||
load:keymap({"i", "s"}, "<c-e>")
|
||||
load:keymap({"i", "s"}, "<c-j>")
|
||||
load:keymap({"i", "s"}, "<c-k>")
|
||||
load:auto("InsertEnter")
|
||||
end,
|
||||
load = function()
|
||||
local ls = require("luasnip")
|
||||
|
||||
-- replace the builtin snippet handler with luasnip so I get all my fancy
|
||||
-- stuff
|
||||
vim.snippet.expand = ls.lsp_expand
|
||||
-- replace the builtin snippet handler with luasnip so I get all my fancy
|
||||
-- stuff
|
||||
vim.snippet.expand = ls.lsp_expand
|
||||
|
||||
ls.config.setup {
|
||||
keep_roots = true,
|
||||
link_roots = true,
|
||||
link_children = true,
|
||||
exit_roots = not true
|
||||
}
|
||||
ls.config.setup {
|
||||
keep_roots = true,
|
||||
link_roots = true,
|
||||
link_children = true,
|
||||
exit_roots = not true
|
||||
}
|
||||
|
||||
map({"i", "s"}, "<C-e>", ls.expand)
|
||||
map({"i", "s"}, "<C-j>", function() ls.jump(1) end)
|
||||
map({"i", "s"}, "<C-k>", function() ls.jump(-1) end)
|
||||
map({"i", "s"}, "<C-a>", function()
|
||||
if ls.choice_active() then
|
||||
ls.change_choice(1)
|
||||
end
|
||||
end)
|
||||
map({"i", "s"}, "<C-e>", ls.expand)
|
||||
map({"i", "s"}, "<C-j>", function() ls.jump(1) end)
|
||||
map({"i", "s"}, "<C-k>", function() ls.jump(-1) end)
|
||||
map({"i", "s"}, "<C-a>", function()
|
||||
if ls.choice_active() then
|
||||
ls.change_choice(1)
|
||||
end
|
||||
end)
|
||||
|
||||
-- collect all snippets and add them
|
||||
for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua",
|
||||
true)) do
|
||||
local fn = file:gsub("^.*/", ""):gsub("%.lua$", "")
|
||||
-- collect all snippets and add them
|
||||
for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua",
|
||||
true)) do
|
||||
local fn = file:gsub("^.*/", ""):gsub("%.lua$", "")
|
||||
|
||||
local ret = require("snippets."..fn)
|
||||
if type(ret) ~= "boolean" then
|
||||
ls.add_snippets(fn, ret, { key = fn })
|
||||
end
|
||||
end
|
||||
end
|
||||
local ret = require("snippets."..fn)
|
||||
if type(ret) ~= "boolean" then
|
||||
ls.add_snippets(fn, ret, { key = fn })
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ return { "mellow-theme/mellow.nvim",
|
|||
["NormalFloat"] = { fg = c.fg, bg = "#111111" },
|
||||
["FloatBorder"] = { bg = "#111111" },
|
||||
|
||||
-- Make pmenu look good
|
||||
["Pmenu"] = { link = "NormalFloat" },
|
||||
["PmenuSel"] = { link = "Normal" },
|
||||
["PmenuKind"] = { link = "@constant" },
|
||||
["PmenuKindSel"] = {
|
||||
fg = core.color.copyhl("Comment").fg,
|
||||
bold = true
|
||||
},
|
||||
-- Make pmenu look good
|
||||
["Pmenu"] = { link = "NormalFloat" },
|
||||
["PmenuSel"] = { link = "Normal" },
|
||||
["PmenuKind"] = { link = "@constant" },
|
||||
["PmenuKindSel"] = {
|
||||
fg = core.color.copyhl("Comment").fg,
|
||||
bold = true
|
||||
},
|
||||
|
||||
-- make diagnostics have an undercurl
|
||||
["DiagnosticUnderlineError"] = { fg = c.red, undercurl = true },
|
||||
|
|
@ -43,19 +43,19 @@ return { "mellow-theme/mellow.nvim",
|
|||
["TelescopePreviewNormal"] = { link = "NormalFloat" },
|
||||
["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 },
|
||||
-- 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
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ return { "stevearc/oil.nvim",
|
|||
for i = 1, #permission_str do
|
||||
local char = permission_str:sub(i, i)
|
||||
table.insert(hls, { ({
|
||||
["-"] = "NonText",
|
||||
["r"] = "DiagnosticSignWarn",
|
||||
["w"] = "DiagnosticSignHint",
|
||||
["x"] = "DiagnosticSignOk"
|
||||
})[char], i - 1, i })
|
||||
["-"] = "NonText",
|
||||
["r"] = "DiagnosticSignWarn",
|
||||
["w"] = "DiagnosticSignHint",
|
||||
["x"] = "DiagnosticSignOk"
|
||||
})[char], i - 1, i })
|
||||
end
|
||||
return hls
|
||||
end,
|
||||
|
|
@ -26,12 +26,12 @@ return { "stevearc/oil.nvim",
|
|||
{ "size", highlight = "@number" }
|
||||
},
|
||||
|
||||
-- fix the damn border
|
||||
confirmation = { winborder = vim.o.winborder },
|
||||
progress = { winborder = vim.o.winborder },
|
||||
ssh = { winborder = vim.o.winborder },
|
||||
keymaps_help = { winborder = vim.o.winborder }
|
||||
}
|
||||
-- fix the damn border
|
||||
confirmation = { winborder = vim.o.winborder },
|
||||
progress = { winborder = vim.o.winborder },
|
||||
ssh = { winborder = vim.o.winborder },
|
||||
keymaps_help = { winborder = vim.o.winborder }
|
||||
}
|
||||
|
||||
map("n", "-", "<cmd>Oil<CR>")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,10 +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
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,72 +44,72 @@ return { "nvim-telescope/telescope.nvim",
|
|||
load = function()
|
||||
local telescope = require("telescope")
|
||||
local actions = require("telescope.actions")
|
||||
local action_state = require("telescope.actions.state")
|
||||
local action_state = require("telescope.actions.state")
|
||||
|
||||
local function send_limited_to_qflist_and_open(prompt_bufnr)
|
||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||
local entries = {}
|
||||
local max_items = 100
|
||||
local count = 0
|
||||
local function send_limited_to_qflist_and_open(prompt_bufnr)
|
||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||
local entries = {}
|
||||
local max_items = 100
|
||||
local count = 0
|
||||
|
||||
for entry in picker.manager:iter() do
|
||||
if count >= max_items then
|
||||
break
|
||||
end
|
||||
for entry in picker.manager:iter() do
|
||||
if count >= max_items then
|
||||
break
|
||||
end
|
||||
|
||||
local filename = entry.path or entry.filename or entry.value
|
||||
local text = entry.text or entry.value
|
||||
if not text then
|
||||
if type(entry.value) == "table" then
|
||||
text = entry.value.text
|
||||
else
|
||||
text = entry.value
|
||||
end
|
||||
end
|
||||
local filename = entry.path or entry.filename or entry.value
|
||||
local text = entry.text or entry.value
|
||||
if not text then
|
||||
if type(entry.value) == "table" then
|
||||
text = entry.value.text
|
||||
else
|
||||
text = entry.value
|
||||
end
|
||||
end
|
||||
|
||||
local pattern
|
||||
if not entry.lnum then
|
||||
if type(entry.display) == "string" then
|
||||
pattern = entry.display
|
||||
elseif type(entry.ordinal) == "string" then
|
||||
pattern = entry.ordinal
|
||||
elseif type(text) == "string" then
|
||||
pattern = text
|
||||
else
|
||||
entry.lnum = 1
|
||||
end
|
||||
end
|
||||
local pattern
|
||||
if not entry.lnum then
|
||||
if type(entry.display) == "string" then
|
||||
pattern = entry.display
|
||||
elseif type(entry.ordinal) == "string" then
|
||||
pattern = entry.ordinal
|
||||
elseif type(text) == "string" then
|
||||
pattern = text
|
||||
else
|
||||
entry.lnum = 1
|
||||
end
|
||||
end
|
||||
|
||||
if filename then
|
||||
table.insert(entries, {
|
||||
filename = filename,
|
||||
text = text,
|
||||
lnum = entry.lnum,
|
||||
col = entry.col,
|
||||
if filename then
|
||||
table.insert(entries, {
|
||||
filename = filename,
|
||||
text = text,
|
||||
lnum = entry.lnum,
|
||||
col = entry.col,
|
||||
|
||||
-- we try and put a pattern in based on the info we receive from
|
||||
-- telescope so that the qf list takes us to the correct place
|
||||
pattern = pattern
|
||||
})
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
-- we try and put a pattern in based on the info we receive from
|
||||
-- telescope so that the qf list takes us to the correct place
|
||||
pattern = pattern
|
||||
})
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
if #entries > 0 then
|
||||
-- make sure errors get suppressed. I don't care
|
||||
pcall(vim.fn.setqflist, {}, " ", {
|
||||
title = "Telescope Limited Results",
|
||||
items = entries
|
||||
})
|
||||
end
|
||||
if #entries > 0 then
|
||||
-- make sure errors get suppressed. I don't care
|
||||
pcall(vim.fn.setqflist, {}, " ", {
|
||||
title = "Telescope Limited Results",
|
||||
items = entries
|
||||
})
|
||||
end
|
||||
|
||||
actions.select_default(prompt_bufnr)
|
||||
end
|
||||
actions.select_default(prompt_bufnr)
|
||||
end
|
||||
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
layout_strategy = "bottom_pane",
|
||||
borderchars = { " ", " ", " ", " ", " ", " ", " ", " " },
|
||||
layout_strategy = "bottom_pane",
|
||||
borderchars = { " ", " ", " ", " ", " ", " ", " ", " " },
|
||||
mappings = {
|
||||
i = {
|
||||
["<esc>"] = actions.close,
|
||||
|
|
@ -119,11 +119,11 @@ return { "nvim-telescope/telescope.nvim",
|
|||
}
|
||||
}
|
||||
},
|
||||
pickers = {
|
||||
colorscheme = {
|
||||
enable_preview = true
|
||||
}
|
||||
},
|
||||
pickers = {
|
||||
colorscheme = {
|
||||
enable_preview = true
|
||||
}
|
||||
},
|
||||
extensions = {
|
||||
fzf = {}
|
||||
}
|
||||
|
|
@ -154,6 +154,6 @@ return { "nvim-telescope/telescope.nvim",
|
|||
}
|
||||
end, { desc = "find files in plugin directory" })
|
||||
|
||||
map("n", "<leader>tt", "<cmd>Telescope<CR>")
|
||||
map("n", "<leader>tt", "<cmd>Telescope<CR>")
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,11 +49,11 @@ return {
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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
|
||||
},
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ return {
|
|||
|
||||
{ "windwp/nvim-ts-autotag",
|
||||
reqs = "nvim-treesitter/nvim-treesitter",
|
||||
disable = true,
|
||||
disable = true,
|
||||
-- lazy = dep_short.auto({ "BufReadPre", "BufNewFile" }),
|
||||
load = function()
|
||||
require("nvim-ts-autotag").setup {}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ local M = {}
|
|||
function M.copyhl(hlgroup, namespace)
|
||||
namespace = namespace or 0
|
||||
local res = {
|
||||
["foreground"] = "#ff0000",
|
||||
["background"] = "#ff0000",
|
||||
["special"] = "#ff0000"
|
||||
}
|
||||
["foreground"] = "#ff0000",
|
||||
["background"] = "#ff0000",
|
||||
["special"] = "#ff0000"
|
||||
}
|
||||
|
||||
local ok, hl = pcall(vim.api.nvim_get_hl, namespace, {
|
||||
name = hlgroup,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ local function on_list(opts)
|
|||
|
||||
-- get to the closest reference to the cursor (likely the one gr or gd was
|
||||
-- called on)
|
||||
--
|
||||
-- TODO: switch this to use opts.idx?
|
||||
--
|
||||
-- TODO: switch this to use opts.idx?
|
||||
local closest, distance = 1, false
|
||||
for i, item in ipairs(opts.items) do
|
||||
if item.filename and vim.fn.expand("%:p") == item.filename then
|
||||
|
|
@ -37,32 +37,32 @@ end
|
|||
|
||||
local group = misc.augroup("lsp.bind")
|
||||
auto("LspAttach", {
|
||||
group = group,
|
||||
callback = function(ctx)
|
||||
local list_opts = { on_list = on_list }
|
||||
local opts = { buffer = ctx.buf, nowait = true }
|
||||
group = group,
|
||||
callback = function(ctx)
|
||||
local list_opts = { on_list = on_list }
|
||||
local opts = { buffer = ctx.buf, nowait = true }
|
||||
|
||||
-- LSP actions
|
||||
map("n", "K", vim.lsp.buf.hover, opts)
|
||||
map("n", "gd", function() vim.lsp.buf.definition(list_opts) end, opts)
|
||||
map("n", "gD", function() vim.lsp.buf.declaration(list_opts) end, opts)
|
||||
map("n", "gi", function() vim.lsp.buf.implementation(list_opts) end, opts)
|
||||
map("n", "gy", function() vim.lsp.buf.type_definition(list_opts) end, opts)
|
||||
map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts)
|
||||
map("n", "<S-Tab>", vim.lsp.buf.signature_help, opts)
|
||||
map("n", "<leader>r", vim.lsp.buf.rename, opts)
|
||||
map("n", "gA", vim.lsp.buf.code_action, opts)
|
||||
-- LSP actions
|
||||
map("n", "K", vim.lsp.buf.hover, opts)
|
||||
map("n", "gd", function() vim.lsp.buf.definition(list_opts) end, opts)
|
||||
map("n", "gD", function() vim.lsp.buf.declaration(list_opts) end, opts)
|
||||
map("n", "gi", function() vim.lsp.buf.implementation(list_opts) end, opts)
|
||||
map("n", "gy", function() vim.lsp.buf.type_definition(list_opts) end, opts)
|
||||
map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts)
|
||||
map("n", "<S-Tab>", vim.lsp.buf.signature_help, opts)
|
||||
map("n", "<leader>r", vim.lsp.buf.rename, opts)
|
||||
map("n", "gA", 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)
|
||||
map("n", "gb", vim.diagnostic.setqflist, opts)
|
||||
-- Diagnostics
|
||||
map("n", "[d", function()
|
||||
vim.diagnostic.jump({ count = -1 })
|
||||
end, opts)
|
||||
map("n", "]d", function()
|
||||
vim.diagnostic.jump({ count = 1 })
|
||||
end, opts)
|
||||
map("n", "gb", vim.diagnostic.setqflist, opts)
|
||||
|
||||
-- formatting
|
||||
map("n", "<leader>c", vim.lsp.buf.format)
|
||||
end
|
||||
-- formatting
|
||||
map("n", "<leader>c", vim.lsp.buf.format)
|
||||
end
|
||||
})
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@
|
|||
---@param list table list of chars
|
||||
---@param char number|string char to add
|
||||
local function add_to_client(list, char)
|
||||
local c
|
||||
local c
|
||||
|
||||
if type(char) == "string" then
|
||||
c = char
|
||||
elseif type(char) == "number" then
|
||||
c = string.char(char)
|
||||
end
|
||||
if not table.contains(list, c) then
|
||||
table.insert(list, c)
|
||||
end
|
||||
if type(char) == "string" then
|
||||
c = char
|
||||
elseif type(char) == "number" then
|
||||
c = string.char(char)
|
||||
end
|
||||
if not table.contains(list, c) then
|
||||
table.insert(list, c)
|
||||
end
|
||||
end
|
||||
|
||||
-- make sure we can add autos
|
||||
|
|
@ -29,49 +29,49 @@ local completion_group = misc.augroup("lsp.completion")
|
|||
-- Configure the lsp completion menu. In addition to setting up lsp completion
|
||||
-- this also styles it to look nice.
|
||||
auto("LspAttach", {
|
||||
group = completion_group,
|
||||
callback = function(ctx)
|
||||
local client = vim.lsp.get_client_by_id(ctx.data.client_id)
|
||||
if not client or not client:supports_method("textDocument/completion") then
|
||||
return
|
||||
end
|
||||
group = completion_group,
|
||||
callback = function(ctx)
|
||||
local client = vim.lsp.get_client_by_id(ctx.data.client_id)
|
||||
if not client or not client:supports_method("textDocument/completion") then
|
||||
return
|
||||
end
|
||||
|
||||
-- Make completion menu appear whenever you type something.
|
||||
local c = client.server_capabilities.completionProvider.triggerCharacters
|
||||
if c then
|
||||
for i = 32, 126 do
|
||||
add_to_client(c, string.char(i))
|
||||
end
|
||||
end
|
||||
-- Make completion menu appear whenever you type something.
|
||||
local c = client.server_capabilities.completionProvider.triggerCharacters
|
||||
if c then
|
||||
for i = 32, 126 do
|
||||
add_to_client(c, string.char(i))
|
||||
end
|
||||
end
|
||||
|
||||
vim.lsp.completion.enable(true, client.id, ctx.buf, {
|
||||
autotrigger = true,
|
||||
convert = function(item)
|
||||
vim.lsp.completion.enable(true, client.id, ctx.buf, {
|
||||
autotrigger = true,
|
||||
convert = function(item)
|
||||
local kind = vim.lsp.protocol.CompletionItemKind[item.kind] or 'u'
|
||||
return {
|
||||
-- in the future if we ever get the ability to highlight specific
|
||||
-- entries in the pummenu I'd like to add treesitter highlighting to
|
||||
-- the entries
|
||||
-- in the future if we ever get the ability to highlight specific
|
||||
-- entries in the pummenu I'd like to add treesitter highlighting to
|
||||
-- the entries
|
||||
abbr = item.label:gsub('%b()', ''),
|
||||
kind = kind:sub(1, 1):lower(),
|
||||
menu = ''
|
||||
}
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
-- attempt to style the completion documentation popup
|
||||
auto("CompleteChanged", {
|
||||
group = completion_group,
|
||||
callback = function()
|
||||
local info = vim.fn.complete_info({ "selected" })
|
||||
if info.preview_bufnr and vim.bo[info.preview_bufnr].filetype == "" then
|
||||
vim.bo[info.preview_bufnr].filetype = "markdown"
|
||||
vim.wo[info.preview_winid].conceallevel = 2
|
||||
vim.wo[info.preview_winid].concealcursor = "niv"
|
||||
end
|
||||
end
|
||||
group = completion_group,
|
||||
callback = function()
|
||||
local info = vim.fn.complete_info({ "selected" })
|
||||
if info.preview_bufnr and vim.bo[info.preview_bufnr].filetype == "" then
|
||||
vim.bo[info.preview_bufnr].filetype = "markdown"
|
||||
vim.wo[info.preview_winid].conceallevel = 2
|
||||
vim.wo[info.preview_winid].concealcursor = "niv"
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- Add snippet support to lsp clients who don't do it for us. Currently this
|
||||
|
|
@ -81,121 +81,121 @@ auto("CompleteChanged", {
|
|||
-- not follow the c-style function call style. I've only gotten this working in
|
||||
-- lua thus far.
|
||||
auto("CompleteDonePre", {
|
||||
group = completion_group,
|
||||
callback = function()
|
||||
local item = vim.tbl_get(
|
||||
vim.v.completed_item,
|
||||
"user_data",
|
||||
"nvim",
|
||||
"lsp",
|
||||
"completion_item"
|
||||
)
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
group = completion_group,
|
||||
callback = function()
|
||||
local item = vim.tbl_get(
|
||||
vim.v.completed_item,
|
||||
"user_data",
|
||||
"nvim",
|
||||
"lsp",
|
||||
"completion_item"
|
||||
)
|
||||
if not item then
|
||||
return
|
||||
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
|
||||
-- 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 item.label and item.kind and item.insertTextFormat then
|
||||
if item.insertTextFormat ~= 2 and item.kind == 3 then
|
||||
local n_complete_item = vim.v.completed_item
|
||||
-- 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.insertTextFormat ~= 2 and item.kind == 3 then
|
||||
local n_complete_item = vim.v.completed_item
|
||||
|
||||
-- attempt to modify the function args to create a snippet
|
||||
local paren1 = string.find(item.label, "%(")
|
||||
if not paren1 then
|
||||
return
|
||||
end
|
||||
-- attempt to modify the function args to create a snippet
|
||||
local paren1 = string.find(item.label, "%(")
|
||||
if not paren1 then
|
||||
return
|
||||
end
|
||||
|
||||
-- try and create a snippet from a function call
|
||||
local i = 1
|
||||
local text = ""
|
||||
local l_paren = paren1
|
||||
local next, is_paren
|
||||
while not is_paren do
|
||||
-- find the next token
|
||||
next = string.find(item.label, "%,", l_paren + 1)
|
||||
if not next then
|
||||
next = string.find(item.label, "%)", l_paren + 1)
|
||||
if not next then
|
||||
return
|
||||
end
|
||||
is_paren = true
|
||||
end
|
||||
-- try and create a snippet from a function call
|
||||
local i = 1
|
||||
local text = ""
|
||||
local l_paren = paren1
|
||||
local next, is_paren
|
||||
while not is_paren do
|
||||
-- find the next token
|
||||
next = string.find(item.label, "%,", l_paren + 1)
|
||||
if not next then
|
||||
next = string.find(item.label, "%)", l_paren + 1)
|
||||
if not next then
|
||||
return
|
||||
end
|
||||
is_paren = true
|
||||
end
|
||||
|
||||
-- concat text
|
||||
if text == "" then
|
||||
-- start the snippet
|
||||
text = string.sub(item.label, 0, l_paren).."${"..i..":"
|
||||
else
|
||||
-- continue the snippet
|
||||
text = text.."}, ".."${"..i..":"
|
||||
end
|
||||
-- concat text
|
||||
if text == "" then
|
||||
-- start the snippet
|
||||
text = string.sub(item.label, 0, l_paren).."${"..i..":"
|
||||
else
|
||||
-- continue the snippet
|
||||
text = text.."}, ".."${"..i..":"
|
||||
end
|
||||
|
||||
do -- add the content of the argument to the snippet
|
||||
-- we need to account for cases in which the developer uses spaces
|
||||
-- between their commas and code
|
||||
local is_space = string.sub(item.label, l_paren + 1, l_paren + 1)
|
||||
local plus = is_space == " " and 2 or 1
|
||||
do -- add the content of the argument to the snippet
|
||||
-- we need to account for cases in which the developer uses spaces
|
||||
-- between their commas and code
|
||||
local is_space = string.sub(item.label, l_paren + 1, l_paren + 1)
|
||||
local plus = is_space == " " and 2 or 1
|
||||
|
||||
text = text..string.sub(item.label, l_paren + plus, next - 1)
|
||||
end
|
||||
text = text..string.sub(item.label, l_paren + plus, next - 1)
|
||||
end
|
||||
|
||||
-- increment
|
||||
l_paren = next
|
||||
i = i + 1
|
||||
end
|
||||
-- end the snippet
|
||||
text = text.."})"
|
||||
-- increment
|
||||
l_paren = next
|
||||
i = i + 1
|
||||
end
|
||||
-- end the snippet
|
||||
text = text.."})"
|
||||
|
||||
n_complete_item.user_data.nvim.lsp.completion_item.insertText = text
|
||||
n_complete_item.user_data.nvim.lsp.completion_item.insertTextFormat = 2
|
||||
n_complete_item.user_data.nvim.lsp.completion_item.kind = 3
|
||||
vim.v.completed_item = n_complete_item
|
||||
end
|
||||
end
|
||||
end
|
||||
n_complete_item.user_data.nvim.lsp.completion_item.insertText = text
|
||||
n_complete_item.user_data.nvim.lsp.completion_item.insertTextFormat = 2
|
||||
n_complete_item.user_data.nvim.lsp.completion_item.kind = 3
|
||||
vim.v.completed_item = n_complete_item
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- show the signature help when inside a function call
|
||||
auto("CompleteDone", {
|
||||
group = completion_group,
|
||||
callback = function(ctx)
|
||||
-- make sure there's an lsp client, and make sure the lsp client supports
|
||||
-- textDocument/signatureHelp
|
||||
local client = vim.lsp.get_clients({ bufnr = ctx.buf })[1]
|
||||
if not client or not client:supports_method("textDocument/signatureHelp") then
|
||||
return
|
||||
end
|
||||
group = completion_group,
|
||||
callback = function(ctx)
|
||||
-- make sure there's an lsp client, and make sure the lsp client supports
|
||||
-- textDocument/signatureHelp
|
||||
local client = vim.lsp.get_clients({ bufnr = ctx.buf })[1]
|
||||
if not client or not client:supports_method("textDocument/signatureHelp") then
|
||||
return
|
||||
end
|
||||
|
||||
-- show the signature help
|
||||
local item = vim.tbl_get(
|
||||
vim.v.completed_item,
|
||||
"user_data",
|
||||
"nvim",
|
||||
"lsp",
|
||||
"completion_item"
|
||||
)
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
-- show the signature help
|
||||
local item = vim.tbl_get(
|
||||
vim.v.completed_item,
|
||||
"user_data",
|
||||
"nvim",
|
||||
"lsp",
|
||||
"completion_item"
|
||||
)
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
|
||||
-- show signature help when the completion is a function
|
||||
if item.kind == 3 and (item.textEdit ~= nil or item.insertText ~= nil) then
|
||||
-- for some reason calling vim.schedule didn't work for me
|
||||
vim.defer_fn(vim.lsp.buf.signature_help, 100)
|
||||
end
|
||||
end,
|
||||
desc = "Auto show signature help when completion is done"
|
||||
-- show signature help when the completion is a function
|
||||
if item.kind == 3 and (item.textEdit ~= nil or item.insertText ~= nil) then
|
||||
-- for some reason calling vim.schedule didn't work for me
|
||||
vim.defer_fn(vim.lsp.buf.signature_help, 100)
|
||||
end
|
||||
end,
|
||||
desc = "Auto show signature help when completion is done"
|
||||
})
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ function M.setup()
|
|||
capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
}
|
||||
|
||||
require("core.lsp.binds")
|
||||
require("core.lsp.completion")
|
||||
require("core.lsp.wtf")
|
||||
require("core.lsp.binds")
|
||||
require("core.lsp.completion")
|
||||
require("core.lsp.wtf")
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -9,29 +9,29 @@ auto('LspAttach', {
|
|||
group = wtf_group,
|
||||
callback = function(ctx)
|
||||
local client = vim.lsp.get_client_by_id(ctx.data.client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
|
||||
-- highlight color codes via lsp (supported by cssls)
|
||||
-- #ff0000
|
||||
-- highlight color codes via lsp (supported by cssls)
|
||||
_ = "#ff0000"
|
||||
if client:supports_method('textDocument/documentColor') then
|
||||
pcall(vim.lsp.document_color.enable, true, ctx.buf)
|
||||
end
|
||||
|
||||
-- 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
|
||||
-- to </a>
|
||||
-- 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
|
||||
-- to </a>
|
||||
if client:supports_method('textDocument/linkedEditingRange') then
|
||||
pcall(vim.lsp.linked_editing_range.enable, true, { client_id = client.id })
|
||||
pcall(vim.lsp.linked_editing_range.enable, true, { client_id = client.id })
|
||||
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
|
||||
-- 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
|
||||
})
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ function M.map(mode, bind, cmd, opts)
|
|||
end
|
||||
end
|
||||
|
||||
vim.keymap.set(mode, bind, cmd, opts)
|
||||
vim.keymap.set(mode, bind, cmd, opts)
|
||||
end
|
||||
|
||||
--- a small map wrapper to easily create local buffer mappings
|
||||
|
|
@ -56,18 +56,18 @@ end
|
|||
---@return string|function lazified
|
||||
---@nodiscard
|
||||
function M.lz(txt)
|
||||
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
|
||||
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
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -3,17 +3,17 @@ dofile(core.snippets)
|
|||
return {
|
||||
-- print inspect text
|
||||
s("inspect", {
|
||||
t("print(vim.inspect("),
|
||||
i(0),
|
||||
t("))")
|
||||
t("print(vim.inspect("),
|
||||
i(0),
|
||||
t("))")
|
||||
}),
|
||||
|
||||
-- print inspect text
|
||||
s("M", {
|
||||
i(1, "M");
|
||||
t({ " = {}", "" }),
|
||||
i(0),
|
||||
t({ "", "return " }),
|
||||
r(1)
|
||||
i(1, "M");
|
||||
t({ " = {}", "" }),
|
||||
i(0),
|
||||
t({ "", "return " }),
|
||||
r(1)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue