diff --git a/lazy-lock.json b/lazy-lock.json index ed04dfe..f768409 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -6,6 +6,7 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-snippy": { "branch": "master", "commit": "6e39210aa3a74e2bf6462f492eaf0d436cd2b7d3" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "cyberdream.nvim": { "branch": "main", "commit": "e510399867656973bbedcededf6d32f52fa82b57" }, "fidget": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" }, "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, "gitsigns.nvim": { "branch": "main", "commit": "ac5aba6dce8c06ea22bea2c9016f51a2dbf90dc7" }, @@ -19,9 +20,10 @@ "nvim-snippy": { "branch": "master", "commit": "86a0b645551ca83153a594097ee0267498abaae2" }, "nvim-tree.lua": { "branch": "master", "commit": "db8d7ac1f524fc6f808764b29fa695c51e014aa6" }, "nvim-treesitter": { "branch": "master", "commit": "2d5c122af9c3c842d74a137446dae8ff349206ac" }, - "oxocarbon.nvim": { "branch": "main", "commit": "004777819ba294423b638a35a75c9f0c7be758ed" }, + "nvim-ufo": { "branch": "main", "commit": "4c64d89c2bf174d95d4ac91cc959a9e43e2f318c" }, "plenary": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, "snacks.nvim": { "branch": "main", "commit": "9651a931043359fcc094ab5c67ac22554a602745" }, "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, "trouble.nvim": { "branch": "main", "commit": "3dc00c0447c016cd43e03054c3d49436a1f2076d" }, diff --git a/lua/andr3/plugins/lsp.lua b/lua/andr3/plugins/lsp.lua index 3e30801..48ef844 100644 --- a/lua/andr3/plugins/lsp.lua +++ b/lua/andr3/plugins/lsp.lua @@ -118,6 +118,13 @@ return { opts = {} }, + { + 'kevinhwang91/nvim-ufo', + dependencies = { + 'kevinhwang91/promise-async', + }, + }, + { "neovim/nvim-lspconfig", dependencies = { @@ -132,6 +139,7 @@ return { 'dcampos/nvim-snippy', 'dcampos/cmp-snippy', 'fidget', + 'kevinhwang91/nvim-ufo', }, config = function() @@ -159,10 +167,17 @@ return { setup_attach() setup_cmp() + -- This is required by UFO + local pre_capabilities = vim.lsp.protocol.make_client_capabilities() + pre_capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true + } + local capabilities = vim.tbl_deep_extend( "force", {}, - vim.lsp.protocol.make_client_capabilities(), + pre_capabilities, require('cmp_nvim_lsp').default_capabilities() ) @@ -192,6 +207,51 @@ return { capabilities = capabilities, } + -- + -- UFO stuff (folding) + -- + + 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 + + require('ufo').setup({ + fold_virt_text_handler = handler + }) + + + -- vim.keymap.set('n', 'zf', require('ufo').closeFoldsWith) + vim.keymap.set('n', 'zR', require('ufo').openAllFolds) + vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) + + -- + -- END UFO stuff (folding) + -- + vim.api.nvim_create_autocmd('LspAttach', { callback = function(args) local client = vim.lsp.get_client_by_id(args.data.client_id) diff --git a/lua/andr3/plugins/themes.lua b/lua/andr3/plugins/themes.lua index 17f46e8..5fbf9d5 100644 --- a/lua/andr3/plugins/themes.lua +++ b/lua/andr3/plugins/themes.lua @@ -53,11 +53,18 @@ return { -- vim.cmd[[colorscheme tokyonight-day]] -- end -- } -{ - "nyoom-engineering/oxocarbon.nvim", - config = function() - vim.opt.background = "dark" -- set this to dark or light - vim.cmd.colorscheme "oxocarbon" - end -} + -- { + -- "nyoom-engineering/oxocarbon.nvim", + -- config = function() + -- vim.opt.background = "dark" -- set this to dark or light + -- vim.cmd.colorscheme "oxocarbon" + -- end + -- } + { + "scottmckendry/cyberdream.nvim", + config = function() + vim.opt.background = "dark" -- set this to dark or light + vim.cmd.colorscheme "cyberdream" + end + } } diff --git a/lua/andr3/plugins/utils.lua b/lua/andr3/plugins/utils.lua index 286f1f7..7bf23e5 100644 --- a/lua/andr3/plugins/utils.lua +++ b/lua/andr3/plugins/utils.lua @@ -89,7 +89,7 @@ return { local api = require "nvim-tree.api" vim.keymap.set('n', '', function() api.tree.toggle() end) end - } + }, -- { -- 'wellle/context.vim', -- } diff --git a/lua/andr3/set.lua b/lua/andr3/set.lua index 836f917..58a115b 100644 --- a/lua/andr3/set.lua +++ b/lua/andr3/set.lua @@ -20,7 +20,12 @@ vim.opt.termguicolors = true vim.opt.cursorline = true vim.opt.colorcolumn= "100" --- vim.opt.foldenable = false +vim.o.foldcolumn = '1' -- '0' is not bad +vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value +vim.o.foldlevelstart = 99 +vim.o.foldenable = true + +-- vim.opt.foldenable = true -- vim.opt.foldmethod = "indent" vim.filetype.add({