diff --git a/lazy-lock.json b/lazy-lock.json index 8bfdad6..833ca55 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -29,13 +29,15 @@ "netrw.nvim": { "branch": "master", "commit": "90501c62b9b816ed3ed1e912ae9db9af5671a1b2" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-genghis": { "branch": "main", "commit": "cdf584d05ffc9d5c1f247079991552249e4f7487" }, - "nvim-lint": { "branch": "master", "commit": "f126af5345c7472e9a0cdbe1d1a29209be72c4c4" }, - "nvim-lspconfig": { "branch": "master", "commit": "d89f4891f0720cd2598e4bdd60010d8784b2ac8a" }, + "nvim-lint": { "branch": "master", "commit": "0864f81c681e15d9bdc1156fe3a17bd07db5a3ed" }, + "nvim-lspconfig": { "branch": "master", "commit": "d9879110d0422a566fa01d732556f4d5515e1738" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, + "nvim-ufo": { "branch": "main", "commit": "d31e2a9fd572a25a4d5011776677223a8ccb7e35" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, + "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, + "snacks.nvim": { "branch": "main", "commit": "da230e3ca8146da4b73752daaf0a1d07d343c12d" }, "tiny-code-action.nvim": { "branch": "main", "commit": "2b3fa2fbd25496259eaf50987097982f8ad08d1b" }, "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "f64efd33a51ea89bdb847fb3aaf716e96b83ba1a" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, diff --git a/lua/core/lsp.lua b/lua/core/lsp.lua index 888195b..2819d2c 100644 --- a/lua/core/lsp.lua +++ b/lua/core/lsp.lua @@ -75,23 +75,23 @@ vim.lsp.config("basedpyright", { }) vim.lsp.enable("basedpyright") -vim.lsp.config("pylsp", { - settings = { - pylsp = { - plugins = { - -- use black as default formatter - yapf = { enabled = false }, - autopep8 = { enabled = false }, - black = { enabled = true }, - pycodestyle = { - enabled = true, - ignore = { "E203", "E701", "W503" }, - maxLineLength = 88, - }, - }, - }, - }, -}) +-- vim.lsp.config("pylsp", { +-- settings = { +-- pylsp = { +-- plugins = { +-- -- use black as default formatter +-- yapf = { enabled = false }, +-- autopep8 = { enabled = false }, +-- black = { enabled = true }, +-- pycodestyle = { +-- enabled = true, +-- ignore = { "E203", "E701", "W503" }, +-- maxLineLength = 88, +-- }, +-- }, +-- }, +-- }, +-- }) -- latex vim.lsp.config("texlab", { diff --git a/lua/core/options.lua b/lua/core/options.lua index 9402696..4c23248 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -45,6 +45,11 @@ local options = { wildmode = "longest:full,full", wildoptions = "pum", + -- Folds (keep open by default, works well with nvim-ufo) + foldlevel = 99, + foldlevelstart = 99, + foldenable = true, + -- Window splitright = true, splitbelow = true, diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 86e721c..7447bed 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -36,7 +36,7 @@ return { "basedpyright", "bashls", "clangd", - "pylsp", + -- "pylsp", "rust_analyzer", }, -- auto-install configured servers (with lspconfig) diff --git a/lua/plugins/utility.lua b/lua/plugins/utility.lua index 37d4acb..2905895 100644 --- a/lua/plugins/utility.lua +++ b/lua/plugins/utility.lua @@ -187,4 +187,93 @@ return { }, }, }, + + -- fold + { + 'kevinhwang91/nvim-ufo', + -- commit = '5b75cf5', + event = { 'BufReadPost', 'BufNewFile' }, + dependencies = { 'kevinhwang91/promise-async', event = 'BufReadPost' }, + opts = { + provider_selector = function() + return { 'lsp', 'indent' } + end, + fold_virt_text_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, + open_fold_hl_timeout = 0, + }, + keys = { + { 'fd', 'zd', desc = 'Delete fold under cursor' }, + { 'fo', 'zo', desc = 'Open fold under cursor' }, + { 'fO', 'zO', desc = 'Open all folds under cursor' }, + { 'fc', 'zC', desc = 'Close all folds under cursor' }, + { 'fa', 'za', desc = 'Toggle fold under cursor' }, + { 'fA', 'zA', desc = 'Toggle all folds under cursor' }, + { 'fv', 'zv', desc = 'Show cursor line' }, + { + 'fM', + function() + require('ufo').closeAllFolds() + end, + desc = 'Close all folds', + }, + { + 'fR', + function() + require('ufo').openAllFolds() + end, + desc = 'Open all folds', + }, + { + 'fm', + function() + require('ufo').closeFoldsWith() + end, + desc = 'Fold more', + }, + { + 'fr', + function() + require('ufo').openFoldsExceptKinds() + end, + desc = 'Fold less', + }, + { 'fx', 'zx', desc = 'Update folds' }, + { 'fz', 'zz', desc = 'Center this line' }, + { 'ft', 'zt', desc = 'Top this line' }, + { 'fb', 'zb', desc = 'Bottom this line' }, + { 'fg', 'zg', desc = 'Add word to spell list' }, + { 'fw', 'zw', desc = 'Mark word as bad/misspelling' }, + { 'fe', 'ze', desc = 'Right this line' }, + { 'fE', 'zE', desc = 'Delete all folds in current buffer' }, + { 'fs', 'zs', desc = 'Left this line' }, + { 'fH', 'zH', desc = 'Half screen to the left' }, + { 'fL', 'zL', desc = 'Half screen to the right' }, + }, + }, }