Nvim: minor tweaks for multiple plugins, better folds
This commit is contained in:
@@ -21,9 +21,64 @@
|
|||||||
-- },
|
-- },
|
||||||
|
|
||||||
|
|
||||||
return {
|
return
|
||||||
"chrisgrieser/nvim-origami",
|
{
|
||||||
event = "BufReadPost", -- later or on keypress would prevent saving folds
|
{
|
||||||
config = true, -- needed even when using default config
|
"chrisgrieser/nvim-origami",
|
||||||
enabled = true
|
event = "BufReadPost", -- later or on keypress would prevent saving folds
|
||||||
|
opts = {
|
||||||
|
keepFoldsAcrossSessions = false,
|
||||||
|
},
|
||||||
|
enabled = true
|
||||||
|
}, {
|
||||||
|
"kevinhwang91/nvim-ufo",
|
||||||
|
dependencies = {
|
||||||
|
"kevinhwang91/promise-async"
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
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
|
||||||
|
|
||||||
|
vim.cmd [[
|
||||||
|
hi default UfoFoldedFg guifg=Normal.foreground
|
||||||
|
hi default UfoFoldedBg guibg=Visual.background
|
||||||
|
hi default link UfoPreviewSbar PmenuSbar
|
||||||
|
hi default link UfoPreviewThumb PmenuThumb
|
||||||
|
hi default link UfoPreviewWinBar UfoFoldedBg
|
||||||
|
hi default link UfoPreviewCursorLine Visual
|
||||||
|
hi default link UfoFoldedEllipsis Visual
|
||||||
|
hi default link UfoCursorFoldedLine Normal
|
||||||
|
hi Folded gui=NONE guibg=Normal.background
|
||||||
|
]]
|
||||||
|
|
||||||
|
require("ufo").setup({
|
||||||
|
fold_virt_text_handler = handler
|
||||||
|
})
|
||||||
|
end
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ return {
|
|||||||
current_line_blame_opts = {
|
current_line_blame_opts = {
|
||||||
virt_text = true,
|
virt_text = true,
|
||||||
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
||||||
delay = 5000,
|
delay = 2000,
|
||||||
ignore_whitespace = true,
|
ignore_whitespace = true,
|
||||||
},
|
},
|
||||||
current_line_blame_formatter_opts = {
|
current_line_blame_formatter_opts = {
|
||||||
@@ -91,7 +91,7 @@ return {
|
|||||||
sign_priority = 6,
|
sign_priority = 6,
|
||||||
update_debounce = 100,
|
update_debounce = 100,
|
||||||
status_formatter = nil, -- Use default
|
status_formatter = nil, -- Use default
|
||||||
max_file_length = 40000,
|
max_file_length = 4000,
|
||||||
preview_config = {
|
preview_config = {
|
||||||
-- Options passed to nvim_open_win
|
-- Options passed to nvim_open_win
|
||||||
border = 'single',
|
border = 'single',
|
||||||
|
|||||||
@@ -98,8 +98,6 @@ return {
|
|||||||
|
|
||||||
-- Mappings.
|
-- Mappings.
|
||||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
|
||||||
vim.keymap.set('n', '<leader>E', vim.diagnostic.setloclist)
|
vim.keymap.set('n', '<leader>E', vim.diagnostic.setloclist)
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
-- Use an on_attach function to only map the following keys
|
||||||
@@ -115,14 +113,10 @@ return {
|
|||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
|
||||||
--vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
--vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||||
--vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
--vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||||
--vim.keymap.set('n', '<space>wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, opts)
|
--vim.keymap.set('n', '<space>wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, opts)
|
||||||
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
||||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
|
||||||
--vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
|
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
|
||||||
vim.keymap.set('n', '<F6>', '<cmd>ClangdSwitchSourceHeader<CR>', opts)
|
vim.keymap.set('n', '<F6>', '<cmd>ClangdSwitchSourceHeader<CR>', opts)
|
||||||
vim.keymap.set("n", "<leader>q", function() vim.lsp.buf.format{ async = true } end, opts)
|
vim.keymap.set("n", "<leader>q", function() vim.lsp.buf.format{ async = true } end, opts)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
return {
|
return {
|
||||||
'kyazdani42/nvim-tree.lua',
|
'nvim-tree/nvim-tree.lua',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'kyazdani42/nvim-web-devicons',
|
'nvim-tree/nvim-web-devicons',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
vim.g.nvim_tree_refresh_wait = 1000
|
vim.g.nvim_tree_refresh_wait = 1000
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
return {
|
return {
|
||||||
"epwalsh/obsidian.nvim",
|
"epwalsh/obsidian.nvim",
|
||||||
version = "*", -- recommended, use latest release instead of latest commit
|
|
||||||
--lazy = true,
|
--lazy = true,
|
||||||
--ft = "markdown",
|
--ft = "markdown",
|
||||||
-- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault:
|
-- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault:
|
||||||
@@ -10,12 +9,6 @@ return {
|
|||||||
-- "BufReadPre path/to/my-vault/**.md",
|
-- "BufReadPre path/to/my-vault/**.md",
|
||||||
-- "BufNewFile path/to/my-vault/**.md",
|
-- "BufNewFile path/to/my-vault/**.md",
|
||||||
-- },
|
-- },
|
||||||
dependencies = {
|
|
||||||
-- Required.
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
|
|
||||||
-- see below for full list of optional dependencies 👇
|
|
||||||
},
|
|
||||||
opts = {
|
opts = {
|
||||||
workspaces = {
|
workspaces = {
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
return {
|
|
||||||
'dcampos/nvim-snippy',
|
|
||||||
dependencies = {
|
|
||||||
'dcampos/cmp-snippy',
|
|
||||||
'honza/vim-snippets',
|
|
||||||
},
|
|
||||||
event = "InsertEnter",
|
|
||||||
config = function()
|
|
||||||
require('snippy').setup({
|
|
||||||
mappings = {
|
|
||||||
is = {
|
|
||||||
['<cr>'] = 'expand_or_advance',
|
|
||||||
['<S-cr>'] = 'previous',
|
|
||||||
},
|
|
||||||
nx = {
|
|
||||||
['<leader>x'] = 'cut_text',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
@@ -65,7 +65,7 @@ return {
|
|||||||
"yaml",
|
"yaml",
|
||||||
},
|
},
|
||||||
indent = {
|
indent = {
|
||||||
enable = true,
|
enable = false,
|
||||||
},
|
},
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
@@ -84,5 +84,6 @@ return {
|
|||||||
}
|
}
|
||||||
vim.opt.foldmethod = "expr"
|
vim.opt.foldmethod = "expr"
|
||||||
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||||
|
vim.opt.foldlevelstart = 99
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
return {
|
return {
|
||||||
'folke/trouble.nvim',
|
'folke/trouble.nvim',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'kyazdani42/nvim-web-devicons',
|
'nvim-tree/nvim-web-devicons',
|
||||||
},
|
},
|
||||||
config = true,
|
config = true,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user