diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index e63c1f5..aaca346 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,56 +1,60 @@ { - "LuaSnip": { "branch": "master", "commit": "659c4479529a05cc9b05ef762639a09d366cc690" }, + "LuaSnip": { "branch": "master", "commit": "33b06d72d220aa56a7ce80a0dd6f06c70cd82b9d" }, "blame.nvim": { "branch": "main", "commit": "39bb4cda9e658d053a43919b10ca52c0a4d738e1" }, - "cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" }, - "cinnamon.nvim": { "branch": "master", "commit": "ecd211e46a1d4fb0efffbdb2c2bbd59785605870" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "023f795dbcf32d4351b6a9ed2e613d471b5bb812" }, - "copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" }, - "dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" }, - "flutter-tools.nvim": { "branch": "main", "commit": "fb976f0e83296d011be95701085ff4711a89de94" }, - "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, - "fzf-lua": { "branch": "main", "commit": "2a7eb32871a131e24021dd1756865e475fe7e274" }, - "gruvbox-material": { "branch": "master", "commit": "b16dcd787db5ba9302b54ebeac186784c2aed29a" }, + "conform.nvim": { "branch": "master", "commit": "f4e8837878fc5712d053ba3091a73d27d96a09e2" }, + "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, + "fzf-lua": { "branch": "main", "commit": "8330321fa135f7fa9e4855099026c4ad622a0c85" }, + "gruvbox-material": { "branch": "master", "commit": "fca2ff9ba627bbf172548eb52fcbb03f99ba34e9" }, "harpoon": { "branch": "harpoon2", "commit": "a84ab829eaf3678b586609888ef52f7779102263" }, - "inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" }, - "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, - "lspkind.nvim": { "branch": "master", "commit": "a700f1436d4a938b1a1a93c9962dc796afbaef4d" }, + "inc-rename.nvim": { "branch": "main", "commit": "1871ca49ae6ee3e9ebee37955ba10c7b1425974f" }, + "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" }, + "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, "ltex-extra.nvim": { "branch": "master", "commit": "24acd044ce7a26b3cdb537cbd094de37c3e1ac45" }, + "lua-async-await": { "branch": "main", "commit": "652d94df34e97abe2d4a689edbc4270e7ead1a98" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "cab00668464d2914d0752b86168b4a431cc93eb2" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.ai": { "branch": "main", "commit": "31c149067d38b97720d2a179619f7745a0006ecc" }, - "noice.nvim": { "branch": "main", "commit": "6e0c8dcc61282782ac7fa4b9b4b0c910fd3f83d9" }, - "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, - "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, + "mini.ai": { "branch": "main", "commit": "ebb04799794a7f94628153991e6334c3304961b8" }, + "noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" }, + "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, + "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, "nvim-cmp": { "branch": "perf", "commit": "6c3d595f3223c1ae7392d4fde1626355439af6c1" }, - "nvim-dap": { "branch": "master", "commit": "29d1f8814fa4fcc194ec574de998a42a22ebbe4a" }, + "nvim-dap": { "branch": "master", "commit": "567da83810dd9da32f9414d941bc6848715fc102" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, - "nvim-lspconfig": { "branch": "master", "commit": "87c7c83ce62971e0bdb29bb32b8ad2b19c8f95d0" }, + "nvim-java": { "branch": "main", "commit": "a36f50c82f922f352d4ce7ac6a3c6b238b3e0a36" }, + "nvim-java-core": { "branch": "main", "commit": "5b03dca22fee76524a89e1c2dc1d73a9f0b1a3bb" }, + "nvim-java-dap": { "branch": "main", "commit": "55f239532f7a3789d21ea68d1e795abc77484974" }, + "nvim-java-refactor": { "branch": "main", "commit": "ea1420fed5463c9cc976c2b4175f434b3646f0f7" }, + "nvim-java-test": { "branch": "main", "commit": "7f0f40e9c5b7eab5096d8bec6ac04251c6e81468" }, + "nvim-lspconfig": { "branch": "master", "commit": "ae8a01bb40848490548e5d07b97ed972ed43c2f9" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-treesitter": { "branch": "master", "commit": "13c7caf8a602488b37cdefe8543c4cfdd5947d9d" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "3e450cd85243da99dc23ebbf14f9c70e9a0c26a4" }, - "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, + "nvim-treesitter": { "branch": "master", "commit": "5cf3434c694a94fccfca79588654e57053a68572" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, + "nvim-ufo": { "branch": "main", "commit": "95cbe2e99901135704aabdc8732d722cf68b12c9" }, + "nvim-web-devicons": { "branch": "master", "commit": "1736cb81bdc42e1ee206081a161bdb2af68fb7a1" }, "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, - "oil.nvim": { "branch": "master", "commit": "8ea40b5506115b6d355e304dd9ee5089f7d78601" }, + "oil.nvim": { "branch": "master", "commit": "dba037598843973b8c54bc5ce0318db4a0da439d" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "refactoring.nvim": { "branch": "master", "commit": "53ed6854e0bba64d467c58e87084dcf8b1c22d36" }, - "rustaceanvim": { "branch": "master", "commit": "8ece53be36515cb9e76f3d03511643636469502d" }, - "screenkey.nvim": { "branch": "main", "commit": "0589de3c857721e150ea694cfe66d6d0e8aecacb" }, - "smart-splits.nvim": { "branch": "master", "commit": "ea4702652cb1d18811d60f2e206787602a2e946c" }, + "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, + "refactoring.nvim": { "branch": "master", "commit": "2db6d378e873de31d18ade549c2edba64ff1c2e3" }, + "rustaceanvim": { "branch": "master", "commit": "25aab238aad3e58f864274449456bdc339981750" }, + "smart-splits.nvim": { "branch": "master", "commit": "1e8fa136f1be004c75b4f794f86a7103e077b6ca" }, + "snacks.nvim": { "branch": "main", "commit": "33253de59260d40f38ee47faf5c8a7e81f91f42e" }, + "spring-boot.nvim": { "branch": "main", "commit": "218c0c26c14d99feca778e4d13f5ec3e8b1b60f0" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" }, - "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" }, + "vim-fugitive": { "branch": "master", "commit": "320b18fba2a4f2fe3c8225c778c687e0d2620384" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, "vim-tpipeline": { "branch": "master", "commit": "72a624f97730059bab359cb0b58a23433bfec308" }, - "vimtex": { "branch": "master", "commit": "6ee92c7ed2cdc876f499bd5561a65d04dee10d1f" }, - "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } + "vimtex": { "branch": "master", "commit": "b8bb79b5fb27e9030ade92e75cd9375416f2c666" }, + "zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" } } diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index 3ef2e92..be96bd2 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua @@ -19,3 +19,7 @@ vim.keymap.set('x', 'gp', '"+P', { desc = 'Paste from system clipboard' }) vim.keymap.set("n", "", "zz", {desc = "Center cursor after moving down half-page"}) vim.keymap.set("n", "", "zz", {desc = "Center cursor after moving down half-page"}) vim.keymap.set("n", "G", "Gzz", {desc = "Center cursor after moving down half-page"}) +--Run lua stuff (ty teej) +vim.keymap.set("n", "x", "source %") +vim.keymap.set("n", "x", ":.lua") +vim.keymap.set("v", "x", ":lua") diff --git a/.config/nvim/lua/core/variables.lua b/.config/nvim/lua/core/variables.lua index 718d8df..b904088 100644 --- a/.config/nvim/lua/core/variables.lua +++ b/.config/nvim/lua/core/variables.lua @@ -3,8 +3,8 @@ vim.g.mapleader = " " --termguicolors vim.opt.termguicolors = true --Relative line numbers -vim.wo.number=true -vim.wo.relativenumber= true +vim.wo.number = true +vim.wo.relativenumber = true --Remove search highlight vim.opt.hlsearch = false vim.opt.incsearch = true diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 7f96934..ba622d9 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -24,6 +24,28 @@ return { vim.opt.pumheight = 15 local lspkind = require("lspkind") + -- `/` cmdline setup. + cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) + + -- `:` cmdline setup. + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { + name = "cmdline", + option = { + ignore_cmds = { "Man", "!" }, + }, + }, + }), + }) cmp.setup({ snippet = { expand = function(args) @@ -69,21 +91,6 @@ return { show_labelDetails = false })(entry, vim_item) formatted_entry.kind = (formatted_entry.kind or "") .. " " - -- local item = entry:get_completion_item() - -- if item.detail then - -- local detail = item.detail - -- if string.find(detail, "->") ~= nil then - -- local return_arrow = vim.split(detail, "->", { trimempty = true }) - -- detail = vim.trim(return_arrow[2] or "") - -- end - -- if string.len(detail) <= 10 then - -- print("<=10 " .. detail) - -- formatted_entry.menu = detail - -- else - -- print(">10 " .. detail) - -- formatted_entry.menu = nil - -- end - -- end return formatted_entry end }, diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index c7460f1..d3f949c 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -1,18 +1,31 @@ return { - -- Rename variable pop up { - "stevearc/dressing.nvim", - event = "VeryLazy", + "folke/lazydev.nvim", + ft = "lua", opts = { - input = { - override = function(conf) - conf.col = -1 - conf.row = 0 - return conf - end, + library = { + { path = "${3rd}/luv/library", words = { "vim%.uv" } } } } }, + { + 'nvim-java/nvim-java', + priority = 500, + config = function() + require('java').setup() + local lspconfig = require("lspconfig") + local lsp_defaults = lspconfig.util.default_config + local capabilities = + vim.tbl_deep_extend("force", lsp_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities()) + capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true + } + lspconfig["jdtls"].setup({ + capabilities = capabilities, + }) + end + }, { "smjonas/inc-rename.nvim", opts = { @@ -27,151 +40,17 @@ return { }, lazy = false, config = function() - require("refactoring").setup() + require("refactoring").setup({}) end, }, { "williamboman/mason.nvim", event = "VeryLazy", - config = function() - local mason = require("mason") - vim.api.nvim_create_augroup("_mason", { clear = true }) - local options = { - PATH = "skip", - ui = { - icons = { - package_pending = " ", - package_installed = "󰄳 ", - package_uninstalled = " ", - }, - keymaps = { - toggle_server_expand = "", - install_server = "i", - update_server = "u", - check_server_version = "c", - update_all_servers = "U", - check_outdated_servers = "C", - uninstall_server = "X", - cancel_installation = "", - }, - }, - max_concurrent_installers = 10, - } - mason.setup(options) - end, - }, - { - "williamboman/mason-lspconfig.nvim", - event = "VeryLazy", - dependencies = { - "williamboman/mason.nvim" - }, - config = function() - local mason_lspconfig = require("mason-lspconfig") - local lspconfig = require("lspconfig") - - mason_lspconfig.setup({ - automatic_installation = false, - }) - - local lsp_defaults = lspconfig.util.default_config - local capabilities = - vim.tbl_deep_extend("force", lsp_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities()) - - mason_lspconfig.setup_handlers({ - -- This is a default handler that will be called for each installed server (also for new servers that are installed during a session) - function(server_name) - lspconfig[server_name].setup({ - capabilities = capabilities, - }) - end, - ["gopls"] = function() - lspconfig["gopls"].setup({ - capabilities = capabilities, - settings = { - gopls = { - ["ui.completion.usePlaceholders"] = true, - ["ui.diagnostic.staticcheck"] = true, - ["ui.inlayhint.hints"] = { - assignVariablesTypes = true, - compositeLiteralFields = true, - compositeLiteralTypes = true, - constantValues = true, - functionTypeParameters = true, - parameterNames = true, - rangeVariableTypes = true - }, - } - } - }) - end, - ["lua_ls"] = function() - lspconfig["lua_ls"].setup({ - capabilities = capabilities, - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = "LuaJIT", - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { "vim" }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - hint = { enable = true } - }, - }, - }) - end, - ["ltex"] = function() - lspconfig["ltex"].setup({ - capabilities = capabilities, - --Local on attach - on_attach = function(_, _) - -- rest of your on_attach process. - require("ltex_extra").setup() - end, - settings = { - ltex = { - language = "en-GB", - }, - additionalRules = { - enablePickyRules = true, - }, - }, - }) - end, - ["basedpyright"] = function() - lspconfig["basedpyright"].setup({ - capabilities = capabilities, - settings = { - verboseOutput = true, - autoImportCompletion = true, - basedpyright = { - analysis = { - typeCheckingMode = "all", - autoSearchPaths = true, - useLibraryCodeForTypes = true, - diagnosticMode = "openFilesOnly", - indexing = true, - }, - }, - }, - }) - end, - }) - end + opts = {} }, { "neovim/nvim-lspconfig", event = { "BufReadPost", "BufNewFile" }, - dependencies = { - "williamboman/mason-lspconfig.nvim" - }, config = function() local lspconfig = require("lspconfig") @@ -216,10 +95,83 @@ return { end, }) - -- ADD NVIM CMP AS A CAPABILITY local lsp_defaults = lspconfig.util.default_config local capabilities = vim.tbl_deep_extend("force", lsp_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities()) + capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true + } + lspconfig["gopls"].setup({ + capabilities = capabilities, + settings = { + gopls = { + ["ui.completion.usePlaceholders"] = true, + ["ui.diagnostic.staticcheck"] = true, + ["ui.inlayhint.hints"] = { + assignVariablesTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true + }, + } + } + }) + lspconfig["lua_ls"].setup({ + capabilities = capabilities, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + hint = { enable = true } + }, + }, + }) + lspconfig["ltex"].setup({ + capabilities = capabilities, + --Local on attach + on_attach = function(_, _) + -- rest of your on_attach process. + require("ltex_extra").setup() + end, + settings = { + ltex = { + language = "en-GB", + }, + additionalRules = { + enablePickyRules = true, + }, + }, + }) + lspconfig["basedpyright"].setup({ + capabilities = capabilities, + settings = { + verboseOutput = true, + autoImportCompletion = true, + basedpyright = { + analysis = { + typeCheckingMode = "all", + autoSearchPaths = true, + useLibraryCodeForTypes = true, + diagnosticMode = "openFilesOnly", + indexing = true, + }, + }, + }, + }) lspconfig["hls"].setup({ capabilities = capabilities, @@ -232,15 +184,6 @@ return { version = '^5', lazy = false }, - { - 'akinsho/flutter-tools.nvim', - lazy = false, - dependencies = { - 'nvim-lua/plenary.nvim', - 'stevearc/dressing.nvim', -- optional for vim.ui.select - }, - config = true, - }, { "rcarriga/nvim-dap-ui", event = "VeryLazy", diff --git a/.config/nvim/lua/plugins/misc.lua b/.config/nvim/lua/plugins/misc.lua index 3e75761..8595d5b 100644 --- a/.config/nvim/lua/plugins/misc.lua +++ b/.config/nvim/lua/plugins/misc.lua @@ -21,9 +21,30 @@ return { }, }, { - 'eandrju/cellular-automaton.nvim', - config = function() - vim.keymap.set("n", "fml", "CellularAutomaton make_it_rain") - end - } + "folke/snacks.nvim", + priority = 1000, + lazy = false, + opts = { + bigfile = { enabled = true }, + notifier = { enabled = true }, + notify = { enabled = true }, + quickfile = { enabled = true }, + statuscolumn = { enabled = true }, + dashboard = { enabled = true }, + input = { enabled = true }, + lazygit = { + enabled = true, + vim.keymap.set('n', 'lg', function() + Snacks.lazygit.open() + end) + }, + words = { + enabled = true, + debounce = 10, + vim.keymap.set('n', 'gn', function() + Snacks.words.jump(1, true) + end) + }, + }, + }, } diff --git a/.config/nvim/lua/plugins/ui.lua b/.config/nvim/lua/plugins/ui.lua index bd98dc4..1c90e13 100644 --- a/.config/nvim/lua/plugins/ui.lua +++ b/.config/nvim/lua/plugins/ui.lua @@ -19,25 +19,9 @@ return { "folke/noice.nvim", event = "VeryLazy", opts = { - views = { - cmdline_popup = { - position = { - row = "100%", - col = "0%", - }, - size = { - min_width = 60, - width = "97%", - height = "auto", - }, - }, - cmdline_popupmenu = { - relative = "editor", - position = { - row = "85%", - col = "0%", - }, - }, + cmdline = { + enabled = true, + view = "cmdline", }, lsp = { override = { @@ -47,50 +31,13 @@ return { }, }, presets = { - command_palette = true, - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = true, -- enables an input dialog for inc-rename.nvim + inc_rename = true, }, }, dependencies = { "MunifTanjim/nui.nvim", } }, - - -- { - -- "OXY2DEV/markview.nvim", - -- ft = "markdown", - -- dependencies = { - -- "nvim-treesitter/nvim-treesitter", - -- "nvim-tree/nvim-web-devicons", - -- }, - -- opts = { - -- modes = { "n", "no", "c" }, - -- callbacks = { - -- on_enable = function(_, win) - -- vim.wo[win].conceallevel = 2; - -- vim.wo[win].concealcursor = "c"; - -- end - -- } - -- } - -- }, - { - "karb94/neoscroll.nvim", - config = function() - local neoscroll = require('neoscroll') - neoscroll.setup({ - hide_cursor = false, - }) - local keymap = { - [""] = function() neoscroll.ctrl_u({ duration = 150 }) end, - [""] = function() neoscroll.ctrl_d({ duration = 150 }) end, - } - local modes = { 'n', 'v', 'x' } - for key, func in pairs(keymap) do - vim.keymap.set(modes, key, func) - end - end - }, { "folke/zen-mode.nvim", event = "VeryLazy", @@ -99,8 +46,49 @@ return { }, }, { - "NStefan002/screenkey.nvim", - lazy = false, - version = "*", -- or branch = "dev", to use the latest commit - }, + 'kevinhwang91/nvim-ufo', + dependencies = 'kevinhwang91/promise-async', + config = function() + vim.o.foldcolumn = '1' + vim.o.foldlevel = 99 + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + vim.keymap.set('n', 'zR', require('ufo').openAllFolds) + vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) + 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 + + -- global handler + -- `handler` is the 2nd parameter of `setFoldVirtTextHandler`, + -- check out `./lua/ufo.lua` and search `setFoldVirtTextHandler` for detail. + require('ufo').setup({ + fold_virt_text_handler = handler + }) + end + } }