✨ feat(nvim): new extras
- folding - hints (big one, im still figuring out some things about it) - rest-client - typescript mod for the hints (will eventually
This commit is contained in:
parent
dc95858318
commit
011c3a9359
5 changed files with 288 additions and 1 deletions
|
@ -26,7 +26,10 @@
|
|||
"plugins.extras.alpha",
|
||||
"plugins.extras.codeium",
|
||||
"plugins.extras.git",
|
||||
"plugins.extras.github"
|
||||
"plugins.extras.github",
|
||||
"plugins.extras.hints",
|
||||
"plugins.extras.rest-client",
|
||||
"plugins.extras.typescript"
|
||||
],
|
||||
"news": {
|
||||
"NEWS.md": "2123"
|
||||
|
|
116
.config/nvim/lua/plugins/extras/fold.lua
Normal file
116
.config/nvim/lua/plugins/extras/fold.lua
Normal file
|
@ -0,0 +1,116 @@
|
|||
return {
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = "┃" },
|
||||
change = { text = "┃" },
|
||||
delete = { text = "" },
|
||||
topdelete = { text = "" },
|
||||
changedelete = { text = "┃" },
|
||||
untracked = { text = "┇" },
|
||||
},
|
||||
signcolumn = true,
|
||||
numhl = true,
|
||||
},
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
optional = true,
|
||||
init = function()
|
||||
local keys = require("lazyvim.plugins.lsp.keymaps").get()
|
||||
keys[#keys + 1] = { "K", false }
|
||||
end,
|
||||
},
|
||||
{ -- better statuscolumn
|
||||
"luukvbaal/statuscol.nvim",
|
||||
event = { "BufRead", "BufNewFile" },
|
||||
opts = function()
|
||||
local builtin = require("statuscol.builtin")
|
||||
return {
|
||||
ft_ignore = { "neo-tree", "neo-tree-popup", "alpha", "lazy", "mason" },
|
||||
segments = {
|
||||
{ text = { builtin.lnumfunc }, click = "v:lua.ScLa" },
|
||||
{
|
||||
sign = { name = { "Diagnostic*" }, text = { ".*" }, maxwidth = 1, colwidth = 1, auto = true },
|
||||
click = "v:lua.ScSa",
|
||||
},
|
||||
{ text = { builtin.foldfunc, " " }, click = "v:lua.ScFa" },
|
||||
},
|
||||
}
|
||||
end,
|
||||
init = function() end,
|
||||
config = function(_, opts)
|
||||
require("statuscol").setup(opts)
|
||||
end,
|
||||
},
|
||||
{ -- better fold
|
||||
"kevinhwang91/nvim-ufo",
|
||||
event = { "BufRead", "BufNewFile" },
|
||||
dependencies = { "kevinhwang91/promise-async" },
|
||||
init = function()
|
||||
vim.o.foldcolumn = "1"
|
||||
vim.o.foldlevel = 99
|
||||
vim.o.foldlevelstart = 99
|
||||
vim.o.foldenable = true
|
||||
end,
|
||||
opts = function()
|
||||
local handler = function(virtText, lnum, endLnum, width, truncate)
|
||||
local newVirtText = {}
|
||||
local suffix = (" ... %d "):format(endLnum - lnum)
|
||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
local targetWidth = width - sufWidth
|
||||
local curWidth = 0
|
||||
for _, chunk in ipairs(virtText) do
|
||||
local chunkText = chunk[1]
|
||||
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
if targetWidth > curWidth + chunkWidth then
|
||||
table.insert(newVirtText, chunk)
|
||||
else
|
||||
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||
local hlGroup = chunk[2]
|
||||
table.insert(newVirtText, { chunkText, hlGroup })
|
||||
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
-- str width returned from truncate() may less than 2nd argument, need padding
|
||||
if curWidth + chunkWidth < targetWidth then
|
||||
suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
|
||||
end
|
||||
break
|
||||
end
|
||||
curWidth = curWidth + chunkWidth
|
||||
end
|
||||
table.insert(newVirtText, { suffix, "MoreMsg" })
|
||||
return newVirtText
|
||||
end
|
||||
|
||||
return {
|
||||
fold_virt_text_handler = handler,
|
||||
provider_selector = function()
|
||||
return { "treesitter", "indent" }
|
||||
end,
|
||||
open_fold_hl_timeout = 400,
|
||||
close_fold_kinds = { "imports", "comment" },
|
||||
preview = {
|
||||
win_config = { border = { "", "─", "", "", "", "─", "", "" }, winblend = 0 },
|
||||
mappings = {
|
||||
scrollU = "<C-b>",
|
||||
scrollD = "<C-f>",
|
||||
jumpTop = "[",
|
||||
jumpBot = "]",
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("ufo").setup(opts)
|
||||
|
||||
local map = require("lazyvim.util").safe_keymap_set
|
||||
map("n", "K", function()
|
||||
if not require("ufo").peekFoldedLinesUnderCursor() then
|
||||
vim.lsp.buf.hover()
|
||||
end
|
||||
end, { desc = "Peek folded lines under cursor or hover" })
|
||||
end,
|
||||
},
|
||||
}
|
26
.config/nvim/lua/plugins/extras/hints.lua
Normal file
26
.config/nvim/lua/plugins/extras/hints.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
return {
|
||||
{
|
||||
"lvimuser/lsp-inlayhints.nvim",
|
||||
init = function()
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("LspAttach_inlayhints", {}),
|
||||
callback = function(args)
|
||||
if not (args.data and args.data.client_id) then
|
||||
return
|
||||
end
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if client.server_capabilities.inlayHintProvider then
|
||||
local inlayhints = require("lsp-inlayhints")
|
||||
inlayhints.on_attach(client, args.buf)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
opts = {},
|
||||
},
|
||||
{
|
||||
"simrat39/rust-tools.nvim",
|
||||
optional = true,
|
||||
opts = { tools = { inlay_hints = { auto = false } } },
|
||||
},
|
||||
}
|
70
.config/nvim/lua/plugins/extras/rest-client.lua
Normal file
70
.config/nvim/lua/plugins/extras/rest-client.lua
Normal file
|
@ -0,0 +1,70 @@
|
|||
return {
|
||||
{
|
||||
"rest-nvim/rest.nvim",
|
||||
dependencies = {
|
||||
{
|
||||
"gennaro-tedesco/nvim-jqx",
|
||||
ft = { "json", "yaml" },
|
||||
},
|
||||
},
|
||||
ft = { "http" },
|
||||
opts = {
|
||||
-- Open request results in a horizontal split
|
||||
result_split_horizontal = true,
|
||||
-- Keep the http file buffer above|left when split horizontal|vertical
|
||||
result_split_in_place = false,
|
||||
-- Skip SSL verification, useful for unknown certificates
|
||||
skip_ssl_verification = false,
|
||||
-- Encode URL before making request
|
||||
encode_url = true,
|
||||
-- Highlight request on run
|
||||
highlight = {
|
||||
enabled = true,
|
||||
timeout = 150,
|
||||
},
|
||||
result = {
|
||||
-- toggle showing URL, HTTP info, headers at top the of result window
|
||||
show_url = true,
|
||||
show_http_info = true,
|
||||
show_headers = true,
|
||||
-- executables or functions for formatting response body [optional]
|
||||
-- set them to false if you want to disable them
|
||||
formatters = {
|
||||
json = "jq",
|
||||
html = function(body)
|
||||
return vim.fn.system({ "tidy", "-i", "-q", "-" }, body)
|
||||
end,
|
||||
},
|
||||
},
|
||||
-- Jump to request line on run
|
||||
jump_to_request = false,
|
||||
env_file = ".env",
|
||||
custom_dynamic_variables = {},
|
||||
yank_dry_run = true,
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
"<leader>thp",
|
||||
function()
|
||||
require("rest-nvim").run(true)
|
||||
end,
|
||||
desc = "Preview Request",
|
||||
},
|
||||
{
|
||||
"<leader>thr",
|
||||
function()
|
||||
require("rest-nvim").run()
|
||||
end,
|
||||
desc = "Run Request",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
opts = {
|
||||
defaults = {
|
||||
["<leader>th"] = { name = "+http" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
72
.config/nvim/lua/plugins/extras/typescript.lua
Normal file
72
.config/nvim/lua/plugins/extras/typescript.lua
Normal file
|
@ -0,0 +1,72 @@
|
|||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
-- make sure mason installs the server
|
||||
servers = {
|
||||
---@type lspconfig.options.tsserver
|
||||
tsserver = {
|
||||
init_options = {
|
||||
preferences = {
|
||||
disableSuggestions = true,
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
"<leader>co",
|
||||
function()
|
||||
vim.lsp.buf.code_action({
|
||||
apply = true,
|
||||
context = {
|
||||
only = { "source.organizeImports.ts" },
|
||||
diagnostics = {},
|
||||
},
|
||||
})
|
||||
end,
|
||||
desc = "Organize Imports",
|
||||
},
|
||||
},
|
||||
settings = {
|
||||
typescript = {
|
||||
format = {
|
||||
indentSize = vim.o.shiftwidth,
|
||||
convertTabsToSpaces = vim.o.expandtab,
|
||||
tabSize = vim.o.tabstop,
|
||||
},
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = "all",
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = false,
|
||||
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
},
|
||||
},
|
||||
javascript = {
|
||||
format = {
|
||||
indentSize = vim.o.shiftwidth,
|
||||
convertTabsToSpaces = vim.o.expandtab,
|
||||
tabSize = vim.o.tabstop,
|
||||
},
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = "all",
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = false,
|
||||
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
},
|
||||
},
|
||||
completions = {
|
||||
completeFunctionCalls = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
Loading…
Add table
Reference in a new issue