inlay hints
This commit is contained in:
parent
5057bd35b5
commit
16b7a39465
|
@ -53,6 +53,10 @@ M.mason = {
|
||||||
|
|
||||||
-- python
|
-- python
|
||||||
"pyright",
|
"pyright",
|
||||||
|
|
||||||
|
|
||||||
|
-- english??
|
||||||
|
"write-good"
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,12 @@ local opt = vim.opt
|
||||||
local g = vim.g
|
local g = vim.g
|
||||||
g.maplocalleader = ";"
|
g.maplocalleader = ";"
|
||||||
|
|
||||||
opt.foldmethod = "indent"
|
|
||||||
opt.foldnestmax = 10
|
|
||||||
opt.foldlevel = 4
|
|
||||||
opt.signcolumn = "yes"
|
opt.signcolumn = "yes"
|
||||||
opt.spelllang = "en,de"
|
opt.spelllang = "en,de"
|
||||||
opt.clipboard = "" -- don't just use the system clipboard
|
opt.clipboard = "" -- don't just use the system clipboard
|
||||||
opt.wrap = false
|
opt.wrap = false
|
||||||
opt.breakindent = false
|
opt.breakindent = false
|
||||||
opt.spell = false
|
opt.spell = true
|
||||||
opt.list = true
|
opt.list = true
|
||||||
opt.conceallevel = 2
|
opt.conceallevel = 2
|
||||||
opt.undofile = true
|
opt.undofile = true
|
||||||
|
@ -62,6 +59,11 @@ opt.formatoptions = "qnlmBjp" -- see :h fo-table & :h formatoptions
|
||||||
opt.diffopt:append { "iwhite", "indent-heuristic", "algorithm:patience" }
|
opt.diffopt:append { "iwhite", "indent-heuristic", "algorithm:patience" }
|
||||||
opt.wildmode = "longest:full,full" -- Command-line completion mode
|
opt.wildmode = "longest:full,full" -- Command-line completion mode
|
||||||
|
|
||||||
|
-- Folds
|
||||||
|
-- ===
|
||||||
|
|
||||||
|
opt.foldlevel = 10000 -- start with all folds open
|
||||||
|
|
||||||
-- Editor UI
|
-- Editor UI
|
||||||
-- ===
|
-- ===
|
||||||
|
|
||||||
|
|
|
@ -397,6 +397,12 @@ M.ui = {
|
||||||
["<leader>tn"] = { "<cmd>setlocal nonumber!<cr>", "toggle line numbers" },
|
["<leader>tn"] = { "<cmd>setlocal nonumber!<cr>", "toggle line numbers" },
|
||||||
["<leader>trn"] = { "<cmd>setlocal nornu!<cr>", "toggle relative line numbers" },
|
["<leader>trn"] = { "<cmd>setlocal nornu!<cr>", "toggle relative line numbers" },
|
||||||
["<leader>ts"] = { "<cmd>setlocal spell!<cr>", "toggle spell check" },
|
["<leader>ts"] = { "<cmd>setlocal spell!<cr>", "toggle spell check" },
|
||||||
|
["<leader>ti"] = {
|
||||||
|
function()
|
||||||
|
require("lsp-inlayhints").toggle()
|
||||||
|
end,
|
||||||
|
"toggle inlay hints",
|
||||||
|
},
|
||||||
|
|
||||||
-- open windows
|
-- open windows
|
||||||
['<leader>"'] = { "<cmd>vsplit<cr>", "open a new window to the side" },
|
['<leader>"'] = { "<cmd>vsplit<cr>", "open a new window to the side" },
|
||||||
|
|
|
@ -511,82 +511,97 @@ local plugins = {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
},
|
},
|
||||||
opts = function()
|
opts = function()
|
||||||
-- lsp->treesitter->indent
|
-- fancy display function for folds (stolen from nvim-ufo readme)
|
||||||
---@param bufnr number
|
local handler = function(virtText, lnum, endLnum, width, truncate)
|
||||||
---@return table
|
local newVirtText = {}
|
||||||
local function customizeSelector(bufnr)
|
local suffix = (" %d "):format(endLnum - lnum)
|
||||||
local function handleFallbackException(err, providerName)
|
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||||
if type(err) == "string" and err:match "UfoFallbackException" then
|
local targetWidth = width - sufWidth
|
||||||
return require("ufo").getFolds(bufnr, providerName)
|
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
|
else
|
||||||
return require("promise").reject(err)
|
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
|
end
|
||||||
|
break
|
||||||
end
|
end
|
||||||
|
curWidth = curWidth + chunkWidth
|
||||||
return require("ufo")
|
|
||||||
.getFolds(bufnr, "lsp")
|
|
||||||
:catch(function(err)
|
|
||||||
return handleFallbackException(err, "treesitter")
|
|
||||||
end)
|
|
||||||
:catch(function(err)
|
|
||||||
return handleFallbackException(err, "indent")
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
table.insert(newVirtText, { suffix, "MoreMsg" })
|
||||||
local ft_providers = {
|
return newVirtText
|
||||||
vim = "indent",
|
end
|
||||||
python = { "indent" },
|
require("ufo").setup {
|
||||||
git = "",
|
-- use treesitter to get the folds
|
||||||
help = "",
|
provider_selector = function(bufnr, filetype, buftype)
|
||||||
qf = "",
|
return { "treesitter", "indent" }
|
||||||
fugitive = "",
|
|
||||||
fugitiveblame = "",
|
|
||||||
["neo-tree"] = "",
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
open_fold_hl_timeout = 0,
|
|
||||||
preview = {
|
|
||||||
win_config = {
|
|
||||||
border = { "", "─", "", "", "", "─", "", "" },
|
|
||||||
winhighlight = "Normal:Folded",
|
|
||||||
winblend = 10,
|
|
||||||
},
|
|
||||||
mappings = {
|
|
||||||
scrollU = "<C-u>",
|
|
||||||
scrollD = "<C-d>",
|
|
||||||
jumpTop = "[",
|
|
||||||
jumpBot = "]",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Select the fold provider.
|
|
||||||
provider_selector = function(_, filetype, _)
|
|
||||||
return ft_providers[filetype] or customizeSelector
|
|
||||||
end,
|
end,
|
||||||
|
-- apply out fancy fold display
|
||||||
-- Display text for folded lines.
|
fold_virt_text_handler = handler,
|
||||||
---@param text table
|
}
|
||||||
---@param lnum integer
|
end,
|
||||||
---@param endLnum integer
|
},
|
||||||
---@param width integer
|
{
|
||||||
---@return table
|
-- enables UNIX specific stuff in vim,
|
||||||
fold_virt_text_handler = function(text, lnum, endLnum, width)
|
-- specifically:
|
||||||
local suffix = " "
|
-- :SudoWrite
|
||||||
local lines = (" %d "):format(endLnum - lnum)
|
-- :SudoRead
|
||||||
|
-- :Chmod
|
||||||
local cur_width = 0
|
-- and also some more, but those are easy done with shell
|
||||||
for _, section in ipairs(text) do
|
"tpope/vim-eunuch",
|
||||||
cur_width = cur_width + vim.fn.strdisplaywidth(section[1])
|
enabled = false,
|
||||||
end
|
lazy = false,
|
||||||
|
},
|
||||||
suffix = suffix .. (" "):rep(width - cur_width - vim.fn.strdisplaywidth(lines) - 3)
|
{
|
||||||
|
"nvimtools/none-ls.nvim",
|
||||||
table.insert(text, { suffix, "UfoFoldedEllipsis" })
|
optional = true,
|
||||||
table.insert(text, { lines, "Folded" })
|
opts = function(_, opts)
|
||||||
return text
|
local nls = require "null-ls"
|
||||||
|
local source = nls.builtins.diagnostics.write_good.with {
|
||||||
|
diagnostics_postprocess = function(diagnostic)
|
||||||
|
diagnostic.severity = vim.diagnostic.severity.HINT
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
table.insert(opts.sources, source)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lvimuser/lsp-inlayhints.nvim",
|
||||||
|
event = "LspAttach",
|
||||||
|
opts = {
|
||||||
|
inlay_hints = {
|
||||||
|
parameter_hints = { show = true },
|
||||||
|
type_hints = { show = true },
|
||||||
|
only_current_line = false,
|
||||||
|
-- highlight group
|
||||||
|
highlight = "LspInlayHint",
|
||||||
|
-- virt_text priority
|
||||||
|
priority = 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
require("lsp-inlayhints").setup(opts)
|
||||||
|
vim.api.nvim_create_augroup("LspAttach_inlayhints", {})
|
||||||
|
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)
|
||||||
|
require("lsp-inlayhints").on_attach(client, args.buf)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
-- change how the highlighting looks
|
||||||
|
vim.cmd("hi LspInlayHint guibg=bg guifg=#804d66")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,3 +236,7 @@ hypervisors
|
||||||
QEMU
|
QEMU
|
||||||
virt
|
virt
|
||||||
filetypes
|
filetypes
|
||||||
|
Parth
|
||||||
|
Narula
|
||||||
|
wordpress
|
||||||
|
PlexSheep's
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue