diff --git a/lua/custom/configs/overrides.lua b/lua/custom/configs/overrides.lua index 9fbb539..3c2d3e6 100644 --- a/lua/custom/configs/overrides.lua +++ b/lua/custom/configs/overrides.lua @@ -53,6 +53,10 @@ M.mason = { -- python "pyright", + + + -- english?? + "write-good" }, } diff --git a/lua/custom/init.lua b/lua/custom/init.lua index b6bd5f9..754b5c0 100644 --- a/lua/custom/init.lua +++ b/lua/custom/init.lua @@ -2,15 +2,12 @@ local opt = vim.opt local g = vim.g g.maplocalleader = ";" -opt.foldmethod = "indent" -opt.foldnestmax = 10 -opt.foldlevel = 4 opt.signcolumn = "yes" opt.spelllang = "en,de" opt.clipboard = "" -- don't just use the system clipboard opt.wrap = false opt.breakindent = false -opt.spell = false +opt.spell = true opt.list = true opt.conceallevel = 2 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.wildmode = "longest:full,full" -- Command-line completion mode +-- Folds +-- === + +opt.foldlevel = 10000 -- start with all folds open + -- Editor UI -- === diff --git a/lua/custom/mappings.lua b/lua/custom/mappings.lua index e754f21..6e30ebb 100644 --- a/lua/custom/mappings.lua +++ b/lua/custom/mappings.lua @@ -397,6 +397,12 @@ M.ui = { ["tn"] = { "setlocal nonumber!", "toggle line numbers" }, ["trn"] = { "setlocal nornu!", "toggle relative line numbers" }, ["ts"] = { "setlocal spell!", "toggle spell check" }, + ["ti"] = { + function() + require("lsp-inlayhints").toggle() + end, + "toggle inlay hints", + }, -- open windows ['"'] = { "vsplit", "open a new window to the side" }, diff --git a/lua/custom/plugins.lua b/lua/custom/plugins.lua index b1f85a8..b0ed7e9 100644 --- a/lua/custom/plugins.lua +++ b/lua/custom/plugins.lua @@ -511,82 +511,97 @@ local plugins = { "neovim/nvim-lspconfig", }, opts = function() - -- lsp->treesitter->indent - ---@param bufnr number - ---@return table - local function customizeSelector(bufnr) - local function handleFallbackException(err, providerName) - if type(err) == "string" and err:match "UfoFallbackException" then - return require("ufo").getFolds(bufnr, providerName) + -- fancy display function for folds (stolen from nvim-ufo readme) + 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 - 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 + break end + curWidth = curWidth + chunkWidth end - - return require("ufo") - .getFolds(bufnr, "lsp") - :catch(function(err) - return handleFallbackException(err, "treesitter") - end) - :catch(function(err) - return handleFallbackException(err, "indent") - end) + table.insert(newVirtText, { suffix, "MoreMsg" }) + return newVirtText end - - local ft_providers = { - vim = "indent", - python = { "indent" }, - git = "", - help = "", - qf = "", - fugitive = "", - fugitiveblame = "", - ["neo-tree"] = "", - } - - return { - open_fold_hl_timeout = 0, - preview = { - win_config = { - border = { "", "─", "", "", "", "─", "", "" }, - winhighlight = "Normal:Folded", - winblend = 10, - }, - mappings = { - scrollU = "", - scrollD = "", - jumpTop = "[", - jumpBot = "]", - }, - }, - - -- Select the fold provider. - provider_selector = function(_, filetype, _) - return ft_providers[filetype] or customizeSelector + require("ufo").setup { + -- use treesitter to get the folds + provider_selector = function(bufnr, filetype, buftype) + return { "treesitter", "indent" } end, - - -- Display text for folded lines. - ---@param text table - ---@param lnum integer - ---@param endLnum integer - ---@param width integer - ---@return table - fold_virt_text_handler = function(text, lnum, endLnum, width) - local suffix = " 󰇘 " - local lines = (" 󰁂 %d "):format(endLnum - lnum) - - local cur_width = 0 - for _, section in ipairs(text) do - cur_width = cur_width + vim.fn.strdisplaywidth(section[1]) + -- apply out fancy fold display + fold_virt_text_handler = handler, + } + end, + }, + { + -- enables UNIX specific stuff in vim, + -- specifically: + -- :SudoWrite + -- :SudoRead + -- :Chmod + -- and also some more, but those are easy done with shell + "tpope/vim-eunuch", + enabled = false, + lazy = false, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require "null-ls" + local source = nls.builtins.diagnostics.write_good.with { + diagnostics_postprocess = function(diagnostic) + diagnostic.severity = vim.diagnostic.severity.HINT + 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 - - suffix = suffix .. (" "):rep(width - cur_width - vim.fn.strdisplaywidth(lines) - 3) - - table.insert(text, { suffix, "UfoFoldedEllipsis" }) - table.insert(text, { lines, "Folded" }) - return text + 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, }, } diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add index 45bf98b..47c8f62 100644 --- a/spell/en.utf-8.add +++ b/spell/en.utf-8.add @@ -236,3 +236,7 @@ hypervisors QEMU virt filetypes +Parth +Narula +wordpress +PlexSheep's diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl index 0593119..5282ec5 100644 Binary files a/spell/en.utf-8.add.spl and b/spell/en.utf-8.add.spl differ