vim: fix plugin dependencies
This commit is contained in:
parent
3e9376bf82
commit
a652dda18d
2 changed files with 244 additions and 241 deletions
|
@ -1,170 +1,178 @@
|
||||||
local config_telescope = function(_, opts)
|
local telescope = {
|
||||||
local telescope = require 'telescope'
|
'nvim-telescope/telescope.nvim',
|
||||||
local actions = require 'telescope.actions'
|
|
||||||
local actions_layout = require 'telescope.actions.layout'
|
|
||||||
local builtin = require 'telescope.builtin'
|
|
||||||
|
|
||||||
local mappings = {
|
config = function(_, opts)
|
||||||
['<c-l>'] = actions_layout.cycle_layout_next,
|
local telescope = require 'telescope'
|
||||||
['<c-o>'] = actions_layout.toggle_mirror,
|
local actions = require 'telescope.actions'
|
||||||
['<c-q>'] = actions.smart_send_to_qflist + actions.open_qflist,
|
local actions_layout = require 'telescope.actions.layout'
|
||||||
}
|
local builtin = require 'telescope.builtin'
|
||||||
|
|
||||||
local mappings_normal_mode = mappings
|
local mappings = {
|
||||||
local mappings_insert_mode = vim.tbl_extend('force', mappings, {
|
['<c-l>'] = actions_layout.cycle_layout_next,
|
||||||
['<c-j>'] = actions.cycle_history_next,
|
['<c-o>'] = actions_layout.toggle_mirror,
|
||||||
['<c-k>'] = actions.cycle_history_prev,
|
['<c-q>'] = actions.smart_send_to_qflist + actions.open_qflist,
|
||||||
})
|
}
|
||||||
|
|
||||||
telescope.setup {
|
local mappings_normal_mode = mappings
|
||||||
defaults = {
|
local mappings_insert_mode = vim.tbl_extend('force', mappings, {
|
||||||
prompt_prefix = ' ❯ ',
|
['<c-j>'] = actions.cycle_history_next,
|
||||||
selection_caret = ' ', -- Other ideas: ➔
|
['<c-k>'] = actions.cycle_history_prev,
|
||||||
multi_icon = ' ',
|
})
|
||||||
|
|
||||||
layout_strategy = 'flex',
|
telescope.setup {
|
||||||
layout_config = {
|
defaults = {
|
||||||
anchor = 'center',
|
prompt_prefix = ' ❯ ',
|
||||||
width = 0.9,
|
selection_caret = ' ', -- Other ideas: ➔
|
||||||
height = 0.9,
|
multi_icon = ' ',
|
||||||
|
|
||||||
flex = {
|
layout_strategy = 'flex',
|
||||||
flip_columns = 130,
|
layout_config = {
|
||||||
|
anchor = 'center',
|
||||||
|
width = 0.9,
|
||||||
|
height = 0.9,
|
||||||
|
|
||||||
|
flex = {
|
||||||
|
flip_columns = 130,
|
||||||
|
},
|
||||||
|
|
||||||
|
horizontal = {
|
||||||
|
preview_width = 0.5,
|
||||||
|
preview_cutoff = 130,
|
||||||
|
},
|
||||||
|
|
||||||
|
vertical = {
|
||||||
|
preview_height = 0.5,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
horizontal = {
|
cycle_layout_list = {
|
||||||
preview_width = 0.5,
|
{ layout_strategy = 'bottom_pane', layout_config = { width = 1, height = 0.4 }, },
|
||||||
preview_cutoff = 130,
|
'horizontal',
|
||||||
|
'vertical',
|
||||||
},
|
},
|
||||||
|
|
||||||
vertical = {
|
|
||||||
preview_height = 0.5,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
cycle_layout_list = {
|
|
||||||
{ layout_strategy = 'bottom_pane', layout_config = { width = 1, height = 0.4 }, },
|
|
||||||
'horizontal',
|
|
||||||
'vertical',
|
|
||||||
},
|
|
||||||
|
|
||||||
mappings = {
|
|
||||||
i = mappings_insert_mode,
|
|
||||||
n = mappings_normal_mode,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
pickers = {
|
|
||||||
buffers = { prompt_title = ' Buffers ' },
|
|
||||||
find_files = { prompt_title = ' Files ' },
|
|
||||||
git_commits = { prompt_title = ' Commits ' },
|
|
||||||
help_tags = { prompt_title = ' Help tags ' },
|
|
||||||
keymaps = { prompt_title = ' Keymaps ' },
|
|
||||||
live_grep = { prompt_title = ' Live grep ' },
|
|
||||||
vim_options = { prompt_title = ' Vim options ' },
|
|
||||||
man_pages = { prompt_title = ' Man pages ' },
|
|
||||||
},
|
|
||||||
|
|
||||||
extensions = {
|
|
||||||
file_browser = {
|
|
||||||
theme = 'ivy',
|
|
||||||
mappings = {
|
mappings = {
|
||||||
n = {
|
i = mappings_insert_mode,
|
||||||
-- normal mode mappings go here
|
n = mappings_normal_mode,
|
||||||
},
|
},
|
||||||
i = {
|
},
|
||||||
-- insert mode mappings go here
|
|
||||||
|
pickers = {
|
||||||
|
buffers = { prompt_title = ' Buffers ' },
|
||||||
|
find_files = { prompt_title = ' Files ' },
|
||||||
|
git_commits = { prompt_title = ' Commits ' },
|
||||||
|
help_tags = { prompt_title = ' Help tags ' },
|
||||||
|
keymaps = { prompt_title = ' Keymaps ' },
|
||||||
|
live_grep = { prompt_title = ' Live grep ' },
|
||||||
|
vim_options = { prompt_title = ' Vim options ' },
|
||||||
|
man_pages = { prompt_title = ' Man pages ' },
|
||||||
|
},
|
||||||
|
|
||||||
|
extensions = {
|
||||||
|
file_browser = {
|
||||||
|
theme = 'ivy',
|
||||||
|
mappings = {
|
||||||
|
n = {
|
||||||
|
-- normal mode mappings go here
|
||||||
|
},
|
||||||
|
i = {
|
||||||
|
-- insert mode mappings go here
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
local selected_range = function()
|
local selected_range = function()
|
||||||
local _, s_row, s_col, _ = unpack(vim.fn.getpos('v'))
|
local _, s_row, s_col, _ = unpack(vim.fn.getpos('v'))
|
||||||
local _, e_row, e_col, _ = unpack(vim.fn.getpos('.'))
|
local _, e_row, e_col, _ = unpack(vim.fn.getpos('.'))
|
||||||
|
|
||||||
local mode = vim.api.nvim_get_mode().mode
|
local mode = vim.api.nvim_get_mode().mode
|
||||||
local visual_line = (mode == 'V' or mode == 'CTRL-V')
|
local visual_line = (mode == 'V' or mode == 'CTRL-V')
|
||||||
|
|
||||||
if s_row < e_row or (s_row == e_row and s_col <= e_col) then
|
if s_row < e_row or (s_row == e_row and s_col <= e_col) then
|
||||||
if visual_line then s_col, e_col = 1, #vim.fn.getline(e_row) end
|
if visual_line then s_col, e_col = 1, #vim.fn.getline(e_row) end
|
||||||
return s_row - 1, s_col - 1, e_row - 1, e_col
|
return s_row - 1, s_col - 1, e_row - 1, e_col
|
||||||
else
|
else
|
||||||
if visual_line then e_col, s_col = 1, #vim.fn.getline(s_row) end
|
if visual_line then e_col, s_col = 1, #vim.fn.getline(s_row) end
|
||||||
return e_row - 1, e_col - 1, s_row - 1, s_col
|
return e_row - 1, e_col - 1, s_row - 1, s_col
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local selected_text = function()
|
local selected_text = function()
|
||||||
local r0, c0, r1, c1 = selected_range()
|
local r0, c0, r1, c1 = selected_range()
|
||||||
return vim.fn.join(vim.api.nvim_buf_get_text(0, r0, c0, r1, c1, {}), '\n')
|
return vim.fn.join(vim.api.nvim_buf_get_text(0, r0, c0, r1, c1, {}), '\n')
|
||||||
end
|
end
|
||||||
|
|
||||||
local custom = {
|
local custom = {
|
||||||
all_files = function()
|
all_files = function()
|
||||||
builtin.find_files {
|
builtin.find_files {
|
||||||
prompt_title = ' ALL Files ',
|
prompt_title = ' ALL Files ',
|
||||||
hidden = true,
|
hidden = true,
|
||||||
no_ignore = true,
|
no_ignore = true,
|
||||||
no_ignore_parent = true,
|
no_ignore_parent = true,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
dotfiles = function()
|
dotfiles = function()
|
||||||
builtin.find_files {
|
builtin.find_files {
|
||||||
prompt_title = ' Find dotfiles ',
|
prompt_title = ' Find dotfiles ',
|
||||||
cwd = '~/.dotfiles',
|
cwd = '~/.dotfiles',
|
||||||
hidden = true,
|
hidden = true,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
grep_visual = function()
|
grep_visual = function()
|
||||||
local selection = selected_text()
|
local selection = selected_text()
|
||||||
builtin.grep_string {
|
builtin.grep_string {
|
||||||
prompt_title = string.format(' Grep: %s', selection),
|
prompt_title = string.format(' Grep: %s', selection),
|
||||||
search = selection,
|
search = selection,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
man_pages = function()
|
man_pages = function()
|
||||||
-- Fix for macOS Ventura onwards (macOS 13.x <-> Darwin 22.x).
|
-- Fix for macOS Ventura onwards (macOS 13.x <-> Darwin 22.x).
|
||||||
-- See: https://github.com/nvim-telescope/telescope.nvim/issues/2326#issuecomment-1407502328
|
-- See: https://github.com/nvim-telescope/telescope.nvim/issues/2326#issuecomment-1407502328
|
||||||
local uname = vim.loop.os_uname()
|
local uname = vim.loop.os_uname()
|
||||||
local sysname = string.lower(uname.sysname)
|
local sysname = string.lower(uname.sysname)
|
||||||
if sysname == "darwin" then
|
if sysname == "darwin" then
|
||||||
local major_version = tonumber(vim.fn.matchlist(uname.release, [[^\(\d\+\)\..*]])[2]) or 0
|
local major_version = tonumber(vim.fn.matchlist(uname.release, [[^\(\d\+\)\..*]])[2]) or 0
|
||||||
if major_version >= 22 then
|
if major_version >= 22 then
|
||||||
|
builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", "." } }
|
||||||
|
else
|
||||||
|
builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", " " } }
|
||||||
|
end
|
||||||
|
elseif sysname == "freebsd" then
|
||||||
builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", "." } }
|
builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", "." } }
|
||||||
else
|
else
|
||||||
builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", " " } }
|
builtin.man_pages { sections = { 'ALL' } }
|
||||||
end
|
end
|
||||||
elseif sysname == "freebsd" then
|
end,
|
||||||
builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", "." } }
|
}
|
||||||
else
|
|
||||||
builtin.man_pages { sections = { 'ALL' } }
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
map('n', '<leader>fa', custom.all_files, { desc = ' [F]ind [A]ll Files in $PWD' })
|
map('n', '<leader>fa', custom.all_files, { desc = ' [F]ind [A]ll Files in $PWD' })
|
||||||
map('n', '<leader>fb', builtin.buffers, { desc = ' [F]ind [B]uffers' })
|
map('n', '<leader>fb', builtin.buffers, { desc = ' [F]ind [B]uffers' })
|
||||||
map('n', '<leader>fc', builtin.git_commits, { desc = ' [F]ind [C]ommits' })
|
map('n', '<leader>fc', builtin.git_commits, { desc = ' [F]ind [C]ommits' })
|
||||||
map('n', '<leader>fd', custom.dotfiles, { desc = ' [F]ind [D]otfiles' })
|
map('n', '<leader>fd', custom.dotfiles, { desc = ' [F]ind [D]otfiles' })
|
||||||
map('n', '<leader>ff', builtin.find_files, { desc = ' [F]ind [F]iles in $PWD' })
|
map('n', '<leader>ff', builtin.find_files, { desc = ' [F]ind [F]iles in $PWD' })
|
||||||
map('n', '<leader>fg', builtin.live_grep, { desc = ' [F]ind with [G]rep in $PWD' })
|
map('n', '<leader>fg', builtin.live_grep, { desc = ' [F]ind with [G]rep in $PWD' })
|
||||||
map('n', '<leader>fh', builtin.help_tags, { desc = ' [F]ind [H]elp tags' })
|
map('n', '<leader>fh', builtin.help_tags, { desc = ' [F]ind [H]elp tags' })
|
||||||
map('n', '<leader>fk', builtin.keymaps, { desc = ' [F]ind [K]eymaps' })
|
map('n', '<leader>fk', builtin.keymaps, { desc = ' [F]ind [K]eymaps' })
|
||||||
map('n', '<leader>fm', custom.man_pages, { desc = ' [F]ind [M]an pages' })
|
map('n', '<leader>fm', custom.man_pages, { desc = ' [F]ind [M]an pages' })
|
||||||
map('n', '<leader>fo', builtin.vim_options, { desc = ' [F]ind vim [O]ptions' })
|
map('n', '<leader>fo', builtin.vim_options, { desc = ' [F]ind vim [O]ptions' })
|
||||||
map('n', '<leader>fs', builtin.grep_string, { desc = ' [F]ind [S]tring' })
|
map('n', '<leader>fs', builtin.grep_string, { desc = ' [F]ind [S]tring' })
|
||||||
map('v', '<leader>fs', custom.grep_visual, { desc = ' [F]ind visual [S]election' })
|
map('v', '<leader>fs', custom.grep_visual, { desc = ' [F]ind visual [S]election' })
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
file_browser = {
|
local file_browser = {
|
||||||
'nvim-telescope/telescope-file-browser.nvim',
|
'nvim-telescope/telescope-file-browser.nvim',
|
||||||
|
|
||||||
|
dependencies = {
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
},
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
require('telescope').load_extension 'file_browser'
|
require('telescope').load_extension 'file_browser'
|
||||||
vim.keymap.set('n', '<leader>br', '<cmd>Telescope file_browser<cr>', { desc = ' file [BR]owser' })
|
vim.keymap.set('n', '<leader>br', '<cmd>Telescope file_browser<cr>', { desc = ' file [BR]owser' })
|
||||||
|
@ -172,12 +180,7 @@ file_browser = {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'nvim-telescope/telescope.nvim',
|
telescope,
|
||||||
|
file_browser,
|
||||||
config = config_telescope,
|
|
||||||
|
|
||||||
dependencies = {
|
|
||||||
file_browser,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,102 +1,102 @@
|
||||||
return {
|
return {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
{
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
|
||||||
dependencies = {
|
opts = {
|
||||||
'nvim-treesitter/nvim-treesitter-refactor',
|
ensure_installed = {
|
||||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
'bash',
|
||||||
'nvim-treesitter/playground',
|
'c',
|
||||||
|
'cpp',
|
||||||
|
'haskell',
|
||||||
|
'html',
|
||||||
|
'javascript',
|
||||||
|
'latex',
|
||||||
|
'lua',
|
||||||
|
'make',
|
||||||
|
'markdown',
|
||||||
|
'markdown_inline',
|
||||||
|
'python',
|
||||||
|
'query',
|
||||||
|
'toml',
|
||||||
|
'vim',
|
||||||
|
'vimdoc',
|
||||||
|
'yaml',
|
||||||
|
},
|
||||||
|
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
disable = {
|
||||||
|
'help',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
incremental_selection = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
init_selection = 'gnn', -- mapped in normal mode
|
||||||
|
node_incremental = '<CR>', -- mapped in visual mode
|
||||||
|
node_decremental = '<BS>', -- mapped in visual mode
|
||||||
|
scope_incremental = nil, -- disabled, normally mapped in visual mode
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
refactor = {
|
||||||
|
highlight_definitions = { enable = true },
|
||||||
|
highlight_current_scope = { enable = false },
|
||||||
|
|
||||||
|
smart_rename = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
smart_rename = 'grr',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
navigation = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
goto_definition = 'gd', -- default: 'gnd'
|
||||||
|
list_definitions = nil, -- disabled, default: 'gnD'
|
||||||
|
list_definitions_toc = 'gO',
|
||||||
|
goto_next_usage = '<a-*>',
|
||||||
|
goto_previous_usage = '<a-#>',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
textobjects = {
|
||||||
|
select = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
['ab'] = '@block.outer',
|
||||||
|
['ib'] = '@block.inner',
|
||||||
|
['ac'] = '@conditional.outer',
|
||||||
|
['ic'] = '@conditional.inner',
|
||||||
|
['af'] = '@function.outer',
|
||||||
|
['if'] = '@function.inner',
|
||||||
|
['al'] = '@loop.outer',
|
||||||
|
['il'] = '@loop.inner',
|
||||||
|
['aa'] = '@parameter.outer',
|
||||||
|
['ia'] = '@parameter.inner',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
playground = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
config = function(_, opts)
|
||||||
|
require('nvim-treesitter.configs').setup(opts)
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>sp', '<cmd>TSPlaygroundToggle<cr>')
|
||||||
|
vim.keymap.set('n', '<leader>sh', '<cmd>TSHighlightCapturesUnderCursor<cr>')
|
||||||
|
vim.keymap.set('n', '<leader>sn', '<cmd>TSNodeUnderCursor<cr>')
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
opts = {
|
'nvim-treesitter/nvim-treesitter-refactor',
|
||||||
ensure_installed = {
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
'bash',
|
'nvim-treesitter/playground',
|
||||||
'c',
|
|
||||||
'cpp',
|
|
||||||
'haskell',
|
|
||||||
'html',
|
|
||||||
'javascript',
|
|
||||||
'latex',
|
|
||||||
'lua',
|
|
||||||
'make',
|
|
||||||
'markdown',
|
|
||||||
'markdown_inline',
|
|
||||||
'python',
|
|
||||||
'query',
|
|
||||||
'toml',
|
|
||||||
'vim',
|
|
||||||
'vimdoc',
|
|
||||||
'yaml',
|
|
||||||
},
|
|
||||||
|
|
||||||
highlight = {
|
|
||||||
enable = true,
|
|
||||||
disable = {
|
|
||||||
'help',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
incremental_selection = {
|
|
||||||
enable = true,
|
|
||||||
keymaps = {
|
|
||||||
init_selection = 'gnn', -- mapped in normal mode
|
|
||||||
node_incremental = '<CR>', -- mapped in visual mode
|
|
||||||
node_decremental = '<BS>', -- mapped in visual mode
|
|
||||||
scope_incremental = nil, -- disabled, normally mapped in visual mode
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
refactor = {
|
|
||||||
highlight_definitions = { enable = true },
|
|
||||||
highlight_current_scope = { enable = false },
|
|
||||||
|
|
||||||
smart_rename = {
|
|
||||||
enable = true,
|
|
||||||
keymaps = {
|
|
||||||
smart_rename = 'grr',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
navigation = {
|
|
||||||
enable = true,
|
|
||||||
keymaps = {
|
|
||||||
goto_definition = 'gd', -- default: 'gnd'
|
|
||||||
list_definitions = nil, -- disabled, default: 'gnD'
|
|
||||||
list_definitions_toc = 'gO',
|
|
||||||
goto_next_usage = '<a-*>',
|
|
||||||
goto_previous_usage = '<a-#>',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
textobjects = {
|
|
||||||
select = {
|
|
||||||
enable = true,
|
|
||||||
keymaps = {
|
|
||||||
['ab'] = '@block.outer',
|
|
||||||
['ib'] = '@block.inner',
|
|
||||||
['ac'] = '@conditional.outer',
|
|
||||||
['ic'] = '@conditional.inner',
|
|
||||||
['af'] = '@function.outer',
|
|
||||||
['if'] = '@function.inner',
|
|
||||||
['al'] = '@loop.outer',
|
|
||||||
['il'] = '@loop.inner',
|
|
||||||
['aa'] = '@parameter.outer',
|
|
||||||
['ia'] = '@parameter.inner',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
playground = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
config = function(_, opts)
|
|
||||||
require('nvim-treesitter.configs').setup(opts)
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>sp', '<cmd>TSPlaygroundToggle<cr>')
|
|
||||||
vim.keymap.set('n', '<leader>sh', '<cmd>TSHighlightCapturesUnderCursor<cr>')
|
|
||||||
vim.keymap.set('n', '<leader>sn', '<cmd>TSNodeUnderCursor<cr>')
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue