This commit is contained in:
sudacode 2025-02-16 20:11:07 -08:00
parent 8742b343b3
commit 9f6f878fb7
Signed by: sudacode
SSH Key Fingerprint: SHA256:lT5C2bB398DcX6daCF/gYFNSTK3y+Du3oTGUnYzfTEw
6 changed files with 148 additions and 67 deletions

View File

@ -10,7 +10,7 @@
"cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f94f7ba948e32cd302caba1c2ca3f7c697fb4fcf" }, "cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f94f7ba948e32cd302caba1c2ca3f7c697fb4fcf" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"codecompanion.nvim": { "branch": "main", "commit": "0a28b6147d77cac6029da8f751454ce6a65473b2" }, "codecompanion.nvim": { "branch": "main", "commit": "1d6a26b1bb9e3b194d602c1ca7b9582e9f4b0b21" },
"copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" }, "copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" },
"copilot-lualine": { "branch": "main", "commit": "dc4b8ed0f75bc2557b3158c526624bf04ad233ea" }, "copilot-lualine": { "branch": "main", "commit": "dc4b8ed0f75bc2557b3158c526624bf04ad233ea" },
"copilot.lua": { "branch": "master", "commit": "30321e33b03cb924fdcd6a806a0dc6fa0b0eafb9" }, "copilot.lua": { "branch": "master", "commit": "30321e33b03cb924fdcd6a806a0dc6fa0b0eafb9" },
@ -50,6 +50,7 @@
"telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" }, "telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "2a5ceff981501cff8f46871d5402cd3378a8ab6a" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "2a5ceff981501cff8f46871d5402cd3378a8ab6a" },
"telescope-glyph.nvim": { "branch": "master", "commit": "f63f01e129e71cc25b79637610674bbf0be5ce9d" }, "telescope-glyph.nvim": { "branch": "master", "commit": "f63f01e129e71cc25b79637610674bbf0be5ce9d" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "master", "commit": "78857db9e8d819d3cc1a9a7bdc1d39d127a36495" }, "telescope.nvim": { "branch": "master", "commit": "78857db9e8d819d3cc1a9a7bdc1d39d127a36495" },
"toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" },
"vim-commentary": { "branch": "master", "commit": "64a654ef4a20db1727938338310209b6a63f60c9" }, "vim-commentary": { "branch": "master", "commit": "64a654ef4a20db1727938338310209b6a63f60c9" },

View File

@ -1,13 +1,14 @@
local map = vim.keymap.set local map = vim.keymap.set
local Terminal = require("toggleterm.terminal").Terminal local Terminal = require("toggleterm.terminal").Terminal
local notify = require("notify") local notify = require("notify")
local dsplit = require("util.open-docs-in-split")
local function term_factory(cfg) local function term_factory(cfg)
cfg["on_stderr"] = function(_, job, data, name) cfg["on_stderr"] = function(_, job, data, name)
notify(name .. " encountered an error on job: " .. job .. "\nData: " .. data) notify(name .. " encountered an error on job: " .. job .. "\nData: " .. data, "error")
end end
cfg["on_stdout"] = function(_, job, data, name) cfg["on_stdout"] = function(_, job, data, name)
notify(name .. " output for job" .. job .. "\nData: " .. data) notify(name .. " output for job" .. job .. "\nData: " .. data, "info")
end end
return Terminal:new(cfg) return Terminal:new(cfg)
end end
@ -122,6 +123,7 @@ map("n", "gl", vim.lsp.codelens.run, opts)
map("n", "gr", ":Telescope lsp_references<CR>", opts) map("n", "gr", ":Telescope lsp_references<CR>", opts)
map("n", "gs", vim.lsp.buf.signature_help, opts) map("n", "gs", vim.lsp.buf.signature_help, opts)
map("n", "K", vim.lsp.buf.hover, opts) map("n", "K", vim.lsp.buf.hover, opts)
map("n", "<leader>kv", dsplit, opts)
map("n", "<leader>cd", ":Telescope lsp_definitions<CR>") map("n", "<leader>cd", ":Telescope lsp_definitions<CR>")
map("n", "<leader>ca", vim.lsp.buf.code_action) map("n", "<leader>ca", vim.lsp.buf.code_action)
map("n", "<leader>cci", ":Telescope lsp_incoming_calls<CR>") map("n", "<leader>cci", ":Telescope lsp_incoming_calls<CR>")
@ -133,11 +135,12 @@ map("n", "<leader>cR", ":lua vim.lsp.buf.rename()<CR>")
map("n", "<leader>cs", ":Telescope lsp_document_symbols<CR>") map("n", "<leader>cs", ":Telescope lsp_document_symbols<CR>")
map("n", "<leader>ct", ":Telescope lsp_type_definitions<CR>") map("n", "<leader>ct", ":Telescope lsp_type_definitions<CR>")
map("n", "<leader>cw", ":Telescope lsp_dynamic_workspace_symbols<CR>") map("n", "<leader>cw", ":Telescope lsp_dynamic_workspace_symbols<CR>")
map("n", "<leader>cd", ":Telescope diagnostics<CR>") map("n", "<leader>cd", ":Telescope diagnostics theme=dropdown layout_config={width=0.8}<CR>")
map("n", "<leader>cDs", ":Telescope diagnostics<CR>") map("n", "<leader>cDs", ":Telescope diagnostics theme=dropdown layout_config={width=0.8}<CR>")
map("n", "<leader>cDn", ":lua vim.diagnostic.goto_next()<CR>") map("n", "<leader>cDn", ":lua vim.diagnostic.goto_next()<CR>")
map("n", "<leader>cDp", ":lua vim.diagnostic.goto_prev()<CR<CR>") map("n", "<leader>cDp", ":lua vim.diagnostic.goto_prev()<CR<CR>")
map("n", "<leader>cl", ":lua vim.diagnostic.setloclist()<CR>") map("n", "<leader>cl", ":lua vim.diagnostic.setloclist()<CR>")
map("n", "<leader>cH", open_doc_in_vsplit, opts)
--}}} --}}}
--{{{ Code Companion and Copilot --{{{ Code Companion and Copilot
@ -157,15 +160,22 @@ map("v", "<leader>Ct", ":CodeCompanion /tests<CR>", notsilent)
--{{{ Telescope mappings --{{{ Telescope mappings
-- {{{ Telescope Finders -- {{{ Telescope Finders
map("n", "//", ":Telescope current_buffer_fuzzy_find<CR>", opts) map("n", "//", ":Telescope current_buffer_fuzzy_find previewer=false<CR>", opts)
map("n", "??", ":Telescope lsp_document_symbols<CR>", opts) map("n", "??", ":Telescope lsp_document_symbols theme=dropdown layout_config={width=0.5}<CR>", opts)
map( map(
"n", "n",
"<leader>fc", "<leader>fc",
':Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical<CR>', ':Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical<CR>',
opts opts
) )
-- map('n', '<leader>ob', ':Telescope file_browser<CR>') map(
"n",
"<leader>Tc",
':Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical<CR>',
opts
)
map("n", "<leader>Tn", ":Telescope notify theme=dropdown layout_config={width=0.75}<CR>", opts)
map( map(
"n", "n",
"<leader>ff", "<leader>ff",
@ -173,6 +183,12 @@ map(
opts opts
) )
map("n", "<leader>fg", ":Telescope live_grep<CR>", opts) map("n", "<leader>fg", ":Telescope live_grep<CR>", opts)
map(
"n",
"<leader>Tg",
':Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical<CR>',
opts
)
map( map(
"n", "n",
"<leader>fG", "<leader>fG",
@ -180,7 +196,7 @@ map(
opts opts
) )
map("n", "<leader>fb", ":Telescope file_browser<CR>", opts) map("n", "<leader>fb", ":Telescope file_browser<CR>", opts)
map("n", "<leader>fr", ":Telescope oldfiles<CR>", opts) map("n", "<leader>fr", ":Telescope oldfiles theme=dropdown layout_config={width=0.5}<CR>", opts)
-- }}} -- }}}
--{{{ Telescope Help --{{{ Telescope Help
@ -188,7 +204,7 @@ map("n", "<leader>hc", ":Telescope commands<CR>")
map("n", "<leader>hv", ":Telescope vim_options<CR>") map("n", "<leader>hv", ":Telescope vim_options<CR>")
map("n", "<leader>hk", ":Telescope keymaps<CR>") map("n", "<leader>hk", ":Telescope keymaps<CR>")
map("n", "<leader>hs", ":Telescope spell_suggest<CR>") map("n", "<leader>hs", ":Telescope spell_suggest<CR>")
map("n", "<leader>hm", ":Telescope man_pages<CR>") map("n", "<leader>hm", ":Telescope man_pages theme=dropdown layout_config={width=0.75}<CR>")
--}}} --}}}
--{{{ Telescope Search --{{{ Telescope Search
@ -210,6 +226,8 @@ map("n", "<leader>gc", ":Telescope git_commits<CR>", opts)
map("n", "<leader>gf", ":Telescope git_files<CR>", opts) map("n", "<leader>gf", ":Telescope git_files<CR>", opts)
--}}} --}}}
map("n", "<leader>Tr", ":Telescope reloader<CR>", opts)
map("n", "Q", ":Telescope cmdline<CR>", opts) map("n", "Q", ":Telescope cmdline<CR>", opts)
map("n", "<leader><leader>", ":Telescope cmdline<CR>", opts) map("n", "<leader><leader>", ":Telescope cmdline<CR>", opts)
--}}} --}}}

View File

@ -86,13 +86,19 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
end end
end end
-- table from lsp severity to vim severity. vim.lsp.handlers["window/showMessage"] = function(err, result, ctx)
local severity = { local client = vim.lsp.get_client_by_id(ctx.client_id)
"error", local lvl = ({
"warn", "ERROR",
"info", "WARN",
"info", -- map both hint and info to info? "INFO",
} "DEBUG",
vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id) })[result.type]
vim.notify(method.message, severity[params.type]) vim.notify("LSP Message: " .. result.message, lvl, {
title = "LSP | " .. client.name,
timeout = 5000,
keep = function()
return lvl == "ERROR" or lvl == "WARN"
end,
})
end end

View File

@ -6,3 +6,4 @@ ts.load_extension("color_names")
ts.load_extension("cmdline") ts.load_extension("cmdline")
ts.load_extension("file_browser") ts.load_extension("file_browser")
ts.load_extension("codecompanion") ts.load_extension("codecompanion")
ts.load_extension("ui-select")

View File

@ -6,6 +6,7 @@ return {
"nat-418/telescope-color-names.nvim", "nat-418/telescope-color-names.nvim",
"nvim-telescope/telescope-file-browser.nvim", "nvim-telescope/telescope-file-browser.nvim",
"ghassan0/telescope-glyph.nvim", "ghassan0/telescope-glyph.nvim",
"nvim-telescope/telescope-ui-select.nvim",
{ {
"nvim-telescope/telescope-fzf-native.nvim", "nvim-telescope/telescope-fzf-native.nvim",
build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release", build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release",
@ -40,6 +41,7 @@ return {
-- actions.which_key shows the mappings for your picker, -- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker -- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] = "which_key", ["<C-h>"] = "which_key",
["<C-u"] = false,
}, },
}, },
file_ignore_patterns = { "^node_modules/", "^env/", "^__pycache__/" }, file_ignore_patterns = { "^node_modules/", "^env/", "^__pycache__/" },
@ -106,6 +108,15 @@ return {
}, },
}, },
}, },
["ui-select"] = {
require("telescope.themes").get_dropdown({
winblend = 10,
width = 0.5,
prompt = " ",
results_height = 15,
previewer = true,
}),
},
}, },
}, },
} }

View File

@ -0,0 +1,44 @@
function open_doc_in_vsplit()
local word = vim.fn.expand("<cword>")
if word == "" then
vim.notify("No word under cursor", vim.log.levels.INFO)
return
end
-- Try to get LSP hover documentation
local params = vim.lsp.util.make_position_params()
local results = vim.lsp.buf_request_sync(0, "textDocument/hover", params, 1000) or {}
local doc_lines = nil
for _, res in pairs(results) do
local contents = res.result and res.result.contents
if contents then
doc_lines = vim.lsp.util.convert_input_to_markdown_lines(contents)
doc_lines = vim.lsp.util.trim_empty_lines(doc_lines)
if #doc_lines > 0 then
break
end
end
end
if doc_lines and #doc_lines > 0 then
-- Open a new vertical split for LSP hover documentation
vim.cmd("vnew")
local bufnr = vim.api.nvim_get_current_buf()
-- Set the buffer to unmodifiable scratch buffer
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, doc_lines)
vim.bo[bufnr].modifiable = false
vim.bo[bufnr].bufhidden = "wipe"
vim.bo[bufnr].filetype = "markdown"
return
end
-- Fallback to vim help command
local help_cmd = "vertical help " .. word
local ok, _ = pcall(vim.cmd, help_cmd)
if not ok then
vim.notify("No documentation available for '" .. word .. "'", vim.log.levels.INFO)
end
end
return open_doc_in_vsplit