1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Martin
ffa7da3773
Merge 4d289d16b3f619e12b62b8971db6818c420e39eb into 2f8482639db32c665f78a211bd007aa9fc14d0c4 2024-02-28 19:23:59 -07:00
jdhao
2f8482639d update some mappings
1. fix a typo in gJ mapping when setting the mark, the correct syntax is
   `mz` (set mark `z`), not `zm`

2. fix bug with `iB` text object: previously `viB` does not work as
   expected, because it does not select the entire buffer as expected.
   After much investigation, I found it is because the `<cmd>` mapping
   argument. If we use `<cmd>` argument for mapping, the mode does not
   change. So if we use `viB`, inititally we are still in visual mode.
   Later in the implementation, when we use `` normal! `<V`>  `` to
   select the entire buffer, it interferes with original visual mode. As
   a result, the entire buffer is not selected. In the text obj
   implementation, we can use `exe "normal! \<Esc>"` to clear the visual
   mode and make `viB`, but this is not ideal. I think it is eaiser to
   just not use the `<cmd>` argument and use `:<C-U>` instead.
2024-02-28 06:36:05 +08:00
martin
4d289d16b3 update nvim-ufo 2024-01-24 22:50:18 +08:00
martin
90a0645d42 add nvim-ufo for folding 2024-01-19 15:44:08 +08:00
4 changed files with 36 additions and 10 deletions

View File

@ -1,6 +1,2 @@
" let the initial folding state be that all folds are closed.
set foldlevel=0
" Use nvim-treesitter for folding
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
setlocal foldlevel=0

22
lua/config/ufo.lua Normal file
View File

@ -0,0 +1,22 @@
local keymap = vim.keymap
-- disable foldcolumn, see https://github.com/kevinhwang91/nvim-ufo/issues/4
vim.o.foldcolumn = '0'
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 -- Don't set nofoldenable in ftplugin
-- treesitter as a main provider instead
-- Only depend on `nvim-treesitter/queries/filetype/folds.scm`,
-- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()`
require('ufo').setup({
provider_selector = function(bufnr, filetype, buftype)
return {'treesitter', 'indent'}
end
})
local ufo = require('ufo')
keymap.set('n', 'zR', ufo.openAllFolds, { desc = 'Open all folds' })
keymap.set('n', 'zM', ufo.closeAllFolds, { desc = 'Close all folds' })
keymap.set('n', 'zr', ufo.openFoldsExceptKinds, { desc = 'Fold less' })
keymap.set('n', 'zm', ufo.closeFoldsWith, { desc = 'Fold more' })

View File

@ -170,7 +170,7 @@ keymap.set("n", "<Down>", "<C-W>j")
keymap.set({ "x", "o" }, "iu", "<cmd>call text_obj#URL()<cr>", { desc = "URL text object" })
-- Text objects for entire buffer
keymap.set({ "x", "o" }, "iB", "<cmd>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
keymap.set({ "x", "o" }, "iB", ":<C-U>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
-- Do not move my cursor when joining lines.
keymap.set("n", "J", function()
@ -179,17 +179,17 @@ keymap.set("n", "J", function()
delmarks z
]])
end, {
desc = "join line",
desc = "join lines without moving cursor",
})
keymap.set("n", "gJ", function()
-- we must use `normal!`, otherwise it will trigger recursive mapping
vim.cmd([[
normal! zmgJ`z
normal! mzgJ`z
delmarks z
]])
end, {
desc = "join visual lines",
desc = "join lines without moving cursor",
})
-- Break inserted text into smaller undo units when we insert some punctuation chars.

View File

@ -50,7 +50,7 @@ local plugin_specs = {
{
"nvim-treesitter/nvim-treesitter",
enabled = function()
if vim.g.is_mac then
if vim.g.is_mac or vim.g.is_linux then
return true
end
return false
@ -489,6 +489,14 @@ local plugin_specs = {
require("config.fidget-nvim")
end,
},
{
'kevinhwang91/nvim-ufo',
dependencies = {'kevinhwang91/promise-async'},
event = { "VeryLazy" },
config = function()
require("config.ufo")
end
}
}
-- configuration for lazy itself.