Folding with nvim-ufo, quickfix mappings
This commit is contained in:
parent
605216bcbb
commit
a1fe12252f
80
init.lua
80
init.lua
|
@ -39,6 +39,7 @@ o.title = true -- Set title of terminal window
|
||||||
o.updatetime = 300 -- Write swap file every 300 ms (supposedly reduces delays)
|
o.updatetime = 300 -- Write swap file every 300 ms (supposedly reduces delays)
|
||||||
o.foldlevel = 99 -- Keep all folds open
|
o.foldlevel = 99 -- Keep all folds open
|
||||||
o.foldlevelstart = 99
|
o.foldlevelstart = 99
|
||||||
|
o.foldenable = true -- Don't disable folds
|
||||||
o.conceallevel = 2 -- Hide concealed text, use replacement if defined
|
o.conceallevel = 2 -- Hide concealed text, use replacement if defined
|
||||||
opt.listchars = { -- Symbols for whitespace chars when 'list' is enabled
|
opt.listchars = { -- Symbols for whitespace chars when 'list' is enabled
|
||||||
tab = '🭰 ',
|
tab = '🭰 ',
|
||||||
|
@ -48,6 +49,9 @@ opt.listchars = { -- Symbols for whitespace chars when 'list' is ena
|
||||||
opt.fillchars = { -- Characters to fill certain types of empty space with
|
opt.fillchars = { -- Characters to fill certain types of empty space with
|
||||||
diff = ' ',
|
diff = ' ',
|
||||||
fold = ' ',
|
fold = ' ',
|
||||||
|
foldopen= '',
|
||||||
|
foldsep=' ',
|
||||||
|
foldclose=''
|
||||||
}
|
}
|
||||||
opt.diffopt:append({'indent-heuristic', 'algorithm:histogram'})
|
opt.diffopt:append({'indent-heuristic', 'algorithm:histogram'})
|
||||||
|
|
||||||
|
@ -111,14 +115,24 @@ do
|
||||||
-- which-key might not be available yet
|
-- which-key might not be available yet
|
||||||
local ok, which_key = pcall(require, 'which-key')
|
local ok, which_key = pcall(require, 'which-key')
|
||||||
if ok then
|
if ok then
|
||||||
which_key.register { ['<C-w>!'] = {'<Cmd>copen<CR>', 'Quickfix window'} }
|
which_key.register {
|
||||||
which_key.register { ['<F2>'] = {'<Cmd>set number! relativenumber!<CR>', 'Toggle relative numbers'} }
|
['<C-w>!'] = {'<Cmd>copen<CR>', 'Quickfix window'},
|
||||||
which_key.register { ['<F3>'] = {'<Cmd>set number!<CR>', 'Toggle line numbers'} }
|
['<F2>'] = {'<Cmd>set number! relativenumber!<CR>', 'Toggle relative numbers'},
|
||||||
|
['<F3>'] = {'<Cmd>set number!<CR>', 'Toggle line numbers'},
|
||||||
which_key.register { ['<A-h>'] = {'<C-w>h', 'Go to the left window'} }
|
['<A-h>'] = {'<C-w>h', 'Go to the left window'},
|
||||||
which_key.register { ['<A-l>'] = {'<C-w>l', 'Go to the right window'} }
|
['<A-l>'] = {'<C-w>l', 'Go to the right window'},
|
||||||
which_key.register { ['<A-n>'] = {'<C-w>n', 'Go to the up window'} }
|
['<A-j>'] = {'<C-w>j', 'Go to the up window'},
|
||||||
which_key.register { ['<A-e>'] = {'<C-w>e', 'Go to the down window'} }
|
['<A-k>'] = {'<C-w>k', 'Go to the down window'},
|
||||||
|
['+'] = {zoom_in, "Zoom in"},
|
||||||
|
['-'] = {zoom_out, "Zoom out"},
|
||||||
|
['<Leader>q'] = {
|
||||||
|
name = 'Quickfix',
|
||||||
|
q = {'<Cmd>copen<CR>', 'Quickfix list'},
|
||||||
|
c = {'<Cmd>cclose<CR>', 'Close quickfix'},
|
||||||
|
n = {'<Cmd>cnext<CR>', 'Next quickfix'},
|
||||||
|
p = {'<Cmd>cprev<CR>', 'Previous quickfix'},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
which_key.register { ['<C-l>'] = {function ()
|
which_key.register { ['<C-l>'] = {function ()
|
||||||
local ok, notify = pcall(require, 'notify')
|
local ok, notify = pcall(require, 'notify')
|
||||||
|
@ -251,6 +265,7 @@ require'packer'.startup(function(use)
|
||||||
use 'mboughaba/i3config.vim'
|
use 'mboughaba/i3config.vim'
|
||||||
use 'plasticboy/vim-markdown'
|
use 'plasticboy/vim-markdown'
|
||||||
use 'mracos/mermaid.vim'
|
use 'mracos/mermaid.vim'
|
||||||
|
use 'lifepillar/pgsql.vim'
|
||||||
use 'ajouellette/sway-vim-syntax'
|
use 'ajouellette/sway-vim-syntax'
|
||||||
use 'cespare/vim-toml'
|
use 'cespare/vim-toml'
|
||||||
use 'rust-lang/rust.vim'
|
use 'rust-lang/rust.vim'
|
||||||
|
@ -285,6 +300,13 @@ require'packer'.startup(function(use)
|
||||||
use {'julian/vim-textobj-variable-segment', requires = {'kana/vim-textobj-user'}, branch = 'main'}
|
use {'julian/vim-textobj-variable-segment', requires = {'kana/vim-textobj-user'}, branch = 'main'}
|
||||||
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}
|
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}
|
||||||
use 'windwp/nvim-ts-autotag'
|
use 'windwp/nvim-ts-autotag'
|
||||||
|
use {'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async', config = function()
|
||||||
|
local ok, ufo = pcall(require, 'ufo')
|
||||||
|
if not ok then return end
|
||||||
|
vim.keymap.set('n', 'zR', ufo.openAllFolds)
|
||||||
|
vim.keymap.set('n', 'zR', ufo.closeAllFolds)
|
||||||
|
ufo.setup {}
|
||||||
|
end}
|
||||||
use 'hrsh7th/vim-vsnip'
|
use 'hrsh7th/vim-vsnip'
|
||||||
|
|
||||||
-- LSP --
|
-- LSP --
|
||||||
|
@ -698,8 +720,8 @@ vim.keymap.set('n', '<Leader>G', '<Cmd>tab Git<CR>', {desc = 'Git status (new ta
|
||||||
require'gitsigns'.setup {
|
require'gitsigns'.setup {
|
||||||
on_attach = function ()
|
on_attach = function ()
|
||||||
local gitsigns = require'gitsigns'
|
local gitsigns = require'gitsigns'
|
||||||
vim.keymap.set('n', ']h', gitsigns.next_hunk, {desc = 'Next hunk'})
|
vim.keymap.set('n', ']c', gitsigns.next_hunk, {desc = 'Next hunk'})
|
||||||
vim.keymap.set('n', '[h', gitsigns.prev_hunk, {desc = 'Previous hunk'})
|
vim.keymap.set('n', '[c', gitsigns.prev_hunk, {desc = 'Previous hunk'})
|
||||||
|
|
||||||
--- Prompt interactively for global comparison base
|
--- Prompt interactively for global comparison base
|
||||||
local function change_base()
|
local function change_base()
|
||||||
|
@ -725,7 +747,7 @@ require'gitsigns'.setup {
|
||||||
d = {gitsigns.toggle_deleted, 'Toggle deleted lines'},
|
d = {gitsigns.toggle_deleted, 'Toggle deleted lines'},
|
||||||
w = {gitsigns.toggle_word_diff, 'Toggle word diffs'},
|
w = {gitsigns.toggle_word_diff, 'Toggle word diffs'},
|
||||||
l = {gitsigns.blame_line, 'Blame current line'},
|
l = {gitsigns.blame_line, 'Blame current line'},
|
||||||
L = {gitsigns.toggle_line_blame, 'Toggle line blame'},
|
L = {gitsigns.toggle_current_line_blame, 'Toggle line blame'},
|
||||||
b = {':Gitsigns change_base ', 'Change diff base'},
|
b = {':Gitsigns change_base ', 'Change diff base'},
|
||||||
B = {gitsigns.reset_base, 'Reset diff base'},
|
B = {gitsigns.reset_base, 'Reset diff base'},
|
||||||
}
|
}
|
||||||
|
@ -797,7 +819,7 @@ cmp.setup {
|
||||||
{'i', 's'}
|
{'i', 's'}
|
||||||
),
|
),
|
||||||
-- Scroll documentation up
|
-- Scroll documentation up
|
||||||
['<C-e'] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}),
|
['<C-e>'] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}),
|
||||||
-- Scroll documentation down
|
-- Scroll documentation down
|
||||||
['<C-y>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}),
|
['<C-y>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}),
|
||||||
-- Complete common substring
|
-- Complete common substring
|
||||||
|
@ -844,7 +866,13 @@ cmp.setup.filetype({'dap-repl', 'dapui_watches', 'dapui_hover'}, {
|
||||||
{ name = 'dap' },
|
{ name = 'dap' },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
-- Which client functionality to tell LSP servers we support
|
||||||
local capabilities = require'cmp_nvim_lsp'.default_capabilities()
|
local capabilities = require'cmp_nvim_lsp'.default_capabilities()
|
||||||
|
-- nvim-ufo folding capabilities
|
||||||
|
capabilities.textDocument.foldingRange = {
|
||||||
|
dynamicRegistration = false,
|
||||||
|
lineFoldingOnly = true,
|
||||||
|
}
|
||||||
|
|
||||||
---- lsp: language servers ----
|
---- lsp: language servers ----
|
||||||
--- Performs keymaps and other setup specific to buffers with LSP enabled
|
--- Performs keymaps and other setup specific to buffers with LSP enabled
|
||||||
|
@ -855,12 +883,12 @@ local function on_attach(client, bufnr)
|
||||||
require'which-key'.register({
|
require'which-key'.register({
|
||||||
['<Leader>l'] = {
|
['<Leader>l'] = {
|
||||||
D = {vim.lsp.buf.declaration, 'Declaration'},
|
D = {vim.lsp.buf.declaration, 'Declaration'},
|
||||||
d = {vim.lsp.buf.definition, 'Definition'},
|
d = {'<Cmd>Telescope lsp_definitions<CR>', 'Definition'},
|
||||||
i = {vim.lsp.buf.implementation, 'Implementation'},
|
i = {'<Cmd>Telescope lsp_implementations<CR>', 'Implementation'},
|
||||||
a = {vim.lsp.buf.code_action, 'Code action'},
|
a = {vim.lsp.buf.code_action, 'Code action'},
|
||||||
r = {vim.lsp.buf.rename, 'Rename'},
|
r = {vim.lsp.buf.rename, 'Rename'},
|
||||||
t = {vim.lsp.buf.type_definition, 'Type definition'},
|
t = {'<Cmd>Telescope lsp_type_definitions<CR>', 'Type definition'},
|
||||||
u = {vim.lsp.buf.references, 'Usages/references'}
|
u = {'<Cmd>Telescope lsp_references<CR>', 'Usages/references'}
|
||||||
},
|
},
|
||||||
g = {
|
g = {
|
||||||
d = {vim.lsp.buf.definition, 'Goto definition'},
|
d = {vim.lsp.buf.definition, 'Goto definition'},
|
||||||
|
@ -888,7 +916,7 @@ local function on_attach(client, bufnr)
|
||||||
['<C-k>'] = {vim.lsp.buf.signature_help, 'Function signature'},
|
['<C-k>'] = {vim.lsp.buf.signature_help, 'Function signature'},
|
||||||
}, {buffer = bufnr})
|
}, {buffer = bufnr})
|
||||||
require'which-key'.register({
|
require'which-key'.register({
|
||||||
['<M-k'] = {vim.lsp.buf.signature_help, 'Function signature'}
|
['<M-k>'] = {vim.lsp.buf.signature_help, 'Function signature'}
|
||||||
}, {buffer = bufnr, mode = 'i'})
|
}, {buffer = bufnr, mode = 'i'})
|
||||||
|
|
||||||
vim.bo.tagfunc = 'v:lua.vim.lsp.tagfunc'
|
vim.bo.tagfunc = 'v:lua.vim.lsp.tagfunc'
|
||||||
|
@ -959,11 +987,11 @@ au('FileType', {
|
||||||
bundles = (function ()
|
bundles = (function ()
|
||||||
-- add java-debug-adapter
|
-- add java-debug-adapter
|
||||||
local bundles = {
|
local bundles = {
|
||||||
vim.fn.glob(vim.fn.stdpath('data') .. '/mason/packages/java-debug-adapter/extension/server/com.microsoft.java.debug.plugin-*.jar', 1)
|
vim.fn.glob(vim.fn.stdpath('data') .. '/mason/packages/java-debug-adapter/extension/server/com.microsoft.java.debug.plugin-*.jar', true)
|
||||||
}
|
}
|
||||||
-- add java-test
|
-- add java-test
|
||||||
vim.list_extend(bundles, vim.split(
|
vim.list_extend(bundles, vim.split(
|
||||||
vim.fn.glob(vim.fn.stdpath'data' .. '/mason/packages/java-test/extension/server/*.jar', 1),
|
vim.fn.glob(vim.fn.stdpath'data' .. '/mason/packages/java-test/extension/server/*.jar', true),
|
||||||
'\n'
|
'\n'
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -971,6 +999,8 @@ au('FileType', {
|
||||||
end)(),
|
end)(),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
capabilities = capabilities,
|
||||||
|
|
||||||
on_attach = function (client, bufnr)
|
on_attach = function (client, bufnr)
|
||||||
on_attach(client, bufnr)
|
on_attach(client, bufnr)
|
||||||
jdtls.setup_dap()
|
jdtls.setup_dap()
|
||||||
|
@ -1171,6 +1201,18 @@ require('nvim-tree').setup {
|
||||||
width = 45,
|
width = 45,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
-- Handle restoring sessions with nvim-tree windows properly
|
||||||
|
au('BufEnter', {
|
||||||
|
pattern = 'NvimTree*',
|
||||||
|
callback = function()
|
||||||
|
local api = require('nvim-tree.api')
|
||||||
|
local view = require('nvim-tree.view')
|
||||||
|
|
||||||
|
if not view.is_visible() then
|
||||||
|
api.tree.open()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
vim.cmd'highlight NvimTreeOpenedFile guifg=NONE guibg=NONE gui=italic'
|
vim.cmd'highlight NvimTreeOpenedFile guifg=NONE guibg=NONE gui=italic'
|
||||||
|
|
||||||
vim.keymap.set('n', '<Leader>t', '<Cmd>NvimTreeFindFile<CR>', {desc = 'Nvim Tree'})
|
vim.keymap.set('n', '<Leader>t', '<Cmd>NvimTreeFindFile<CR>', {desc = 'Nvim Tree'})
|
||||||
|
|
Loading…
Reference in a new issue