vim: refactor configuration of plugins
This commit is contained in:
parent
9a6d090015
commit
1954162b2b
7 changed files with 437 additions and 445 deletions
|
@ -1,12 +1,10 @@
|
||||||
return {
|
return {
|
||||||
'lukas-reineke/indent-blankline.nvim',
|
'lukas-reineke/indent-blankline.nvim',
|
||||||
|
|
||||||
opts = {
|
config = function()
|
||||||
enabled = false,
|
require('indent_blankline').setup {
|
||||||
},
|
enabled = false,
|
||||||
|
}
|
||||||
config = function(_, opts)
|
|
||||||
require('indent_blankline').setup(opts)
|
|
||||||
|
|
||||||
-- show/hide indent guides
|
-- show/hide indent guides
|
||||||
vim.keymap.set('n', '<leader>si', '<cmd>IndentBlanklineToggle<cr>')
|
vim.keymap.set('n', '<leader>si', '<cmd>IndentBlanklineToggle<cr>')
|
||||||
|
|
|
@ -29,25 +29,25 @@ local on_attach = function(client, bufnr)
|
||||||
if filetype_attach then filetype_attach(client, bufnr) end
|
if filetype_attach then filetype_attach(client, bufnr) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local config = function()
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
local has_cmp, cmp = pcall(require, 'cmp_nvim_lsp')
|
||||||
|
if has_cmp then
|
||||||
|
vim.tbl_deep_extend('force', capabilities, cmp.default_capabilities())
|
||||||
|
end
|
||||||
|
|
||||||
|
lsp = require('lspconfig')
|
||||||
|
for server, opts in pairs(servers) do
|
||||||
|
opts = vim.tbl_deep_extend('keep', opts, {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
lsp[server].setup(opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
|
config = config,
|
||||||
config = function()
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
local has_cmp, cmp = pcall(require, 'cmp_nvim_lsp')
|
|
||||||
if has_cmp then
|
|
||||||
vim.tbl_deep_extend('force', capabilities, cmp.default_capabilities())
|
|
||||||
end
|
|
||||||
|
|
||||||
lsp = require('lspconfig')
|
|
||||||
for server, opts in pairs(servers) do
|
|
||||||
opts = vim.tbl_deep_extend('keep', opts, {
|
|
||||||
on_attach = on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
})
|
|
||||||
lsp[server].setup(opts)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,181 +1,182 @@
|
||||||
return {
|
local config = function()
|
||||||
'nvim-lualine/lualine.nvim',
|
local MODE_MAP = {
|
||||||
|
['n'] = 'Normal ',
|
||||||
|
['no'] = 'O-Pend ',
|
||||||
|
['nov'] = 'O-Pend ',
|
||||||
|
['noV'] = 'O-Pend ',
|
||||||
|
['no'] = 'O-Pend ',
|
||||||
|
['niI'] = 'Normal ',
|
||||||
|
['niR'] = 'Normal ',
|
||||||
|
['niV'] = 'Normal ',
|
||||||
|
['nt'] = 'Normal ',
|
||||||
|
['ntT'] = 'Normal*',
|
||||||
|
['v'] = 'Visual ',
|
||||||
|
['vs'] = 'Visual ',
|
||||||
|
['V'] = 'V-Line ',
|
||||||
|
['Vs'] = 'V-Line ',
|
||||||
|
[''] = 'V-Block',
|
||||||
|
['s'] = 'V-Block',
|
||||||
|
['s'] = 'Select ',
|
||||||
|
['S'] = 'S-Line ',
|
||||||
|
[''] = 'S-Block',
|
||||||
|
['i'] = 'Insert ',
|
||||||
|
['ic'] = 'Insert ',
|
||||||
|
['ix'] = 'Insert ',
|
||||||
|
['R'] = 'Replace',
|
||||||
|
['Rc'] = 'Replace',
|
||||||
|
['Rx'] = 'Replace',
|
||||||
|
['Rv'] = 'V-Repl ',
|
||||||
|
['Rvc'] = 'V-Repl ',
|
||||||
|
['Rvx'] = 'V-Repl ',
|
||||||
|
['c'] = 'Command',
|
||||||
|
['cv'] = ' Ex ',
|
||||||
|
['ce'] = ' Ex ',
|
||||||
|
['r'] = 'Replace',
|
||||||
|
['rm'] = ' More ',
|
||||||
|
['r?'] = 'Confirm',
|
||||||
|
['!'] = ' Shell ',
|
||||||
|
['t'] = ' Term ',
|
||||||
|
}
|
||||||
|
|
||||||
config = function()
|
local update_status = function(self, is_focused)
|
||||||
local MODE_MAP = {
|
self.options.colored = is_focused
|
||||||
['n'] = 'Normal ',
|
return self.super.update_status(self, is_focused)
|
||||||
['no'] = 'O-Pend ',
|
end
|
||||||
['nov'] = 'O-Pend ',
|
|
||||||
['noV'] = 'O-Pend ',
|
|
||||||
['no'] = 'O-Pend ',
|
|
||||||
['niI'] = 'Normal ',
|
|
||||||
['niR'] = 'Normal ',
|
|
||||||
['niV'] = 'Normal ',
|
|
||||||
['nt'] = 'Normal ',
|
|
||||||
['ntT'] = 'Normal*',
|
|
||||||
['v'] = 'Visual ',
|
|
||||||
['vs'] = 'Visual ',
|
|
||||||
['V'] = 'V-Line ',
|
|
||||||
['Vs'] = 'V-Line ',
|
|
||||||
[''] = 'V-Block',
|
|
||||||
['s'] = 'V-Block',
|
|
||||||
['s'] = 'Select ',
|
|
||||||
['S'] = 'S-Line ',
|
|
||||||
[''] = 'S-Block',
|
|
||||||
['i'] = 'Insert ',
|
|
||||||
['ic'] = 'Insert ',
|
|
||||||
['ix'] = 'Insert ',
|
|
||||||
['R'] = 'Replace',
|
|
||||||
['Rc'] = 'Replace',
|
|
||||||
['Rx'] = 'Replace',
|
|
||||||
['Rv'] = 'V-Repl ',
|
|
||||||
['Rvc'] = 'V-Repl ',
|
|
||||||
['Rvx'] = 'V-Repl ',
|
|
||||||
['c'] = 'Command',
|
|
||||||
['cv'] = ' Ex ',
|
|
||||||
['ce'] = ' Ex ',
|
|
||||||
['r'] = 'Replace',
|
|
||||||
['rm'] = ' More ',
|
|
||||||
['r?'] = 'Confirm',
|
|
||||||
['!'] = ' Shell ',
|
|
||||||
['t'] = ' Term ',
|
|
||||||
}
|
|
||||||
|
|
||||||
local update_status = function(self, is_focused)
|
local diff = require'lualine.components.diff':extend()
|
||||||
self.options.colored = is_focused
|
diff.update_status = update_status
|
||||||
return self.super.update_status(self, is_focused)
|
|
||||||
end
|
|
||||||
|
|
||||||
local diff = require'lualine.components.diff':extend()
|
local filetype = require'lualine.components.filetype':extend()
|
||||||
diff.update_status = update_status
|
filetype.update_status = update_status
|
||||||
|
|
||||||
local filetype = require'lualine.components.filetype':extend()
|
local window_is_at_least = function(width)
|
||||||
filetype.update_status = update_status
|
return function() return vim.fn.winwidth(0) > width end
|
||||||
|
end
|
||||||
|
|
||||||
local window_is_at_least = function(width)
|
local window_is_wide = window_is_at_least(80)
|
||||||
return function() return vim.fn.winwidth(0) > width end
|
local window_is_medium = window_is_at_least(50)
|
||||||
end
|
|
||||||
|
|
||||||
local window_is_wide = window_is_at_least(80)
|
local parts = {
|
||||||
local window_is_medium = window_is_at_least(50)
|
paste = {
|
||||||
|
function() return '' end,
|
||||||
|
color = { bg = '#bbaa00' },
|
||||||
|
cond = function()
|
||||||
|
return vim.opt.paste:get()
|
||||||
|
end
|
||||||
|
},
|
||||||
|
|
||||||
local parts = {
|
mode = {
|
||||||
paste = {
|
function()
|
||||||
function() return '' end,
|
local code = vim.api.nvim_get_mode().mode
|
||||||
color = { bg = '#bbaa00' },
|
return MODE_MAP[code] or code
|
||||||
cond = function()
|
end,
|
||||||
return vim.opt.paste:get()
|
},
|
||||||
|
|
||||||
|
visual_multi = function()
|
||||||
|
local ok, infos = pcall(vim.fn.VMInfos)
|
||||||
|
if not ok or not infos.status then return '' end
|
||||||
|
return infos.current .. '/' .. infos.total .. ' ' .. infos.status
|
||||||
|
end,
|
||||||
|
|
||||||
|
branch = {
|
||||||
|
'branch',
|
||||||
|
icon = '',
|
||||||
|
cond = window_is_medium,
|
||||||
|
},
|
||||||
|
|
||||||
|
status = {
|
||||||
|
function()
|
||||||
|
local flags = {}
|
||||||
|
if vim.bo.modified then
|
||||||
|
table.insert(flags, '+')
|
||||||
end
|
end
|
||||||
},
|
if vim.bo.modifiable == false or vim.bo.readonly == true then
|
||||||
|
table.insert(flags, 'RO')
|
||||||
mode = {
|
end
|
||||||
function()
|
return table.concat(flags, ' ')
|
||||||
local code = vim.api.nvim_get_mode().mode
|
|
||||||
return MODE_MAP[code] or code
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
visual_multi = function()
|
|
||||||
local ok, infos = pcall(vim.fn.VMInfos)
|
|
||||||
if not ok or not infos.status then return '' end
|
|
||||||
return infos.current .. '/' .. infos.total .. ' ' .. infos.status
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
branch = {
|
color = { fg = '#eee8d5' },
|
||||||
'branch',
|
},
|
||||||
icon = '',
|
|
||||||
cond = window_is_medium,
|
|
||||||
},
|
|
||||||
|
|
||||||
status = {
|
filename = {
|
||||||
function()
|
function()
|
||||||
local flags = {}
|
local shorten_path = function(path)
|
||||||
if vim.bo.modified then
|
if window_is_wide() then
|
||||||
table.insert(flags, '+')
|
return path
|
||||||
|
elseif window_is_medium() then
|
||||||
|
return vim.fn.pathshorten(path) -- only first letter of directories
|
||||||
|
else
|
||||||
|
return vim.fn.fnamemodify(path, ':t') -- only tail
|
||||||
end
|
end
|
||||||
if vim.bo.modifiable == false or vim.bo.readonly == true then
|
end
|
||||||
table.insert(flags, 'RO')
|
|
||||||
end
|
|
||||||
return table.concat(flags, ' ')
|
|
||||||
end,
|
|
||||||
|
|
||||||
color = { fg = '#eee8d5' },
|
return shorten_path(vim.fn.expand('%:~:.'))
|
||||||
},
|
end,
|
||||||
|
|
||||||
filename = {
|
color = function()
|
||||||
function()
|
if vim.bo.modified then
|
||||||
local shorten_path = function(path)
|
return { gui = 'italic' }
|
||||||
if window_is_wide() then
|
end
|
||||||
return path
|
end,
|
||||||
elseif window_is_medium() then
|
|
||||||
return vim.fn.pathshorten(path) -- only first letter of directories
|
|
||||||
else
|
|
||||||
return vim.fn.fnamemodify(path, ':t') -- only tail
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return shorten_path(vim.fn.expand('%:~:.'))
|
padding = { left = 1, right = 0},
|
||||||
end,
|
},
|
||||||
|
|
||||||
color = function()
|
filetype = {
|
||||||
if vim.bo.modified then
|
filetype,
|
||||||
return { gui = 'italic' }
|
cond = window_is_medium,
|
||||||
end
|
},
|
||||||
end,
|
|
||||||
|
|
||||||
padding = { left = 1, right = 0},
|
fileformat = {
|
||||||
},
|
'fileformat',
|
||||||
|
cond = window_is_medium,
|
||||||
|
},
|
||||||
|
|
||||||
filetype = {
|
progress = {
|
||||||
filetype,
|
function()
|
||||||
cond = window_is_medium,
|
local chars = { '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' }
|
||||||
},
|
local current, total = vim.fn.line '.', vim.fn.line '$'
|
||||||
|
return chars[math.ceil(#chars * current / total)]
|
||||||
|
end,
|
||||||
|
padding = { left = 0, right = 1 },
|
||||||
|
cond = window_is_wide,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
fileformat = {
|
local inactive_sections = {
|
||||||
'fileformat',
|
lualine_a = {},
|
||||||
cond = window_is_medium,
|
lualine_b = { parts.visual_multi, parts.branch },
|
||||||
},
|
lualine_c = { parts.filename, parts.status },
|
||||||
|
lualine_x = { 'diagnostics', parts.filetype },
|
||||||
|
lualine_y = { parts.fileformat, parts.progress },
|
||||||
|
lualine_z = { 'location' },
|
||||||
|
}
|
||||||
|
|
||||||
progress = {
|
require('lualine').setup {
|
||||||
function()
|
options = {
|
||||||
local chars = { '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' }
|
icons_enabled = true,
|
||||||
local current, total = vim.fn.line '.', vim.fn.line '$'
|
component_separators = { left = '', right = '' },
|
||||||
return chars[math.ceil(#chars * current / total)]
|
section_separators = { left = '', right = '' },
|
||||||
end,
|
theme = 'solarized',
|
||||||
padding = { left = 0, right = 1 },
|
},
|
||||||
cond = window_is_wide,
|
|
||||||
},
|
sections = vim.tbl_extend('force', inactive_sections, {
|
||||||
|
lualine_a = { parts.paste, parts.mode },
|
||||||
|
}),
|
||||||
|
|
||||||
|
inactive_sections = inactive_sections,
|
||||||
|
|
||||||
|
extensions = {
|
||||||
|
'fugitive',
|
||||||
|
'quickfix',
|
||||||
|
'nvim-tree',
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
local inactive_sections = {
|
return {
|
||||||
lualine_a = {},
|
'nvim-lualine/lualine.nvim',
|
||||||
lualine_b = { parts.visual_multi, parts.branch },
|
config = config,
|
||||||
lualine_c = { parts.filename, parts.status },
|
|
||||||
lualine_x = { 'diagnostics', parts.filetype },
|
|
||||||
lualine_y = { parts.fileformat, parts.progress },
|
|
||||||
lualine_z = { 'location' },
|
|
||||||
}
|
|
||||||
|
|
||||||
require('lualine').setup {
|
|
||||||
options = {
|
|
||||||
icons_enabled = true,
|
|
||||||
component_separators = { left = '', right = '' },
|
|
||||||
section_separators = { left = '', right = '' },
|
|
||||||
theme = 'solarized',
|
|
||||||
},
|
|
||||||
|
|
||||||
sections = vim.tbl_extend('force', inactive_sections, {
|
|
||||||
lualine_a = { parts.paste, parts.mode },
|
|
||||||
}),
|
|
||||||
|
|
||||||
inactive_sections = inactive_sections,
|
|
||||||
|
|
||||||
extensions = {
|
|
||||||
'fugitive',
|
|
||||||
'quickfix',
|
|
||||||
'nvim-tree',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,22 @@
|
||||||
local on_attach = function(bufnr)
|
local config = function()
|
||||||
local api = require('nvim-tree.api')
|
require('nvim-tree').setup {
|
||||||
local opts = function(desc)
|
|
||||||
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, silent = true }
|
|
||||||
end
|
|
||||||
|
|
||||||
api.config.mappings.default_on_attach(bufnr)
|
|
||||||
|
|
||||||
vim.keymap.set('n', 'l', api.node.open.edit, opts('open'))
|
|
||||||
vim.keymap.set('n', '<CR>', api.node.open.edit, opts('open'))
|
|
||||||
vim.keymap.set('n', 'o', api.node.open.edit, opts('open'))
|
|
||||||
vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('close directory'))
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
'kyazdani42/nvim-tree.lua',
|
|
||||||
|
|
||||||
opts = {
|
|
||||||
disable_netrw = true, -- replace netrw with nvim-tree
|
disable_netrw = true, -- replace netrw with nvim-tree
|
||||||
hijack_cursor = true, -- keep the cursor on begin of the filename
|
hijack_cursor = true, -- keep the cursor on begin of the filename
|
||||||
sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree
|
sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree
|
||||||
on_attach = on_attach,
|
|
||||||
|
on_attach = function(bufnr)
|
||||||
|
local api = require('nvim-tree.api')
|
||||||
|
api.config.mappings.default_on_attach(bufnr)
|
||||||
|
|
||||||
|
local opts = function(desc)
|
||||||
|
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, silent = true }
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set('n', 'l', api.node.open.edit, opts('open'))
|
||||||
|
vim.keymap.set('n', '<CR>', api.node.open.edit, opts('open'))
|
||||||
|
vim.keymap.set('n', 'o', api.node.open.edit, opts('open'))
|
||||||
|
vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('close directory'))
|
||||||
|
end,
|
||||||
|
|
||||||
git = {
|
git = {
|
||||||
ignore = false, -- don't hide files from .gitignore
|
ignore = false, -- don't hide files from .gitignore
|
||||||
|
@ -41,14 +37,15 @@ return {
|
||||||
group_empty = true, -- folders that contain only one folder are grouped
|
group_empty = true, -- folders that contain only one folder are grouped
|
||||||
highlight_git = true, -- enable highlight based on git attributes
|
highlight_git = true, -- enable highlight based on git attributes
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
|
|
||||||
config = function(_, opts)
|
vim.keymap.set('n', '<leader>nn', '<cmd>NvimTreeOpen<cr>')
|
||||||
require('nvim-tree').setup(opts)
|
vim.keymap.set('n', '<leader>nf', '<cmd>NvimTreeFindFile<cr>')
|
||||||
|
vim.keymap.set('n', '<leader>nc', '<cmd>NvimTreeClose<cr>')
|
||||||
|
end
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>nn', '<cmd>NvimTreeOpen<cr>')
|
return {
|
||||||
vim.keymap.set('n', '<leader>nf', '<cmd>NvimTreeFindFile<cr>')
|
'kyazdani42/nvim-tree.lua',
|
||||||
vim.keymap.set('n', '<leader>nc', '<cmd>NvimTreeClose<cr>')
|
config = config,
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,177 +1,176 @@
|
||||||
local telescope = {
|
local config = function()
|
||||||
'nvim-telescope/telescope.nvim',
|
local telescope = require 'telescope'
|
||||||
|
local actions = require 'telescope.actions'
|
||||||
|
local actions_layout = require 'telescope.actions.layout'
|
||||||
|
local builtin = require 'telescope.builtin'
|
||||||
|
|
||||||
config = function(_, opts)
|
local mappings = {
|
||||||
local telescope = require 'telescope'
|
['<c-l>'] = actions_layout.cycle_layout_next,
|
||||||
local actions = require 'telescope.actions'
|
['<c-o>'] = actions_layout.toggle_mirror,
|
||||||
local actions_layout = require 'telescope.actions.layout'
|
['<c-q>'] = actions.smart_send_to_qflist + actions.open_qflist,
|
||||||
local builtin = require 'telescope.builtin'
|
}
|
||||||
|
|
||||||
local mappings = {
|
local mappings_normal_mode = mappings
|
||||||
['<c-l>'] = actions_layout.cycle_layout_next,
|
local mappings_insert_mode = vim.tbl_extend('force', mappings, {
|
||||||
['<c-o>'] = actions_layout.toggle_mirror,
|
['<c-j>'] = actions.cycle_history_next,
|
||||||
['<c-q>'] = actions.smart_send_to_qflist + actions.open_qflist,
|
['<c-k>'] = actions.cycle_history_prev,
|
||||||
}
|
})
|
||||||
|
|
||||||
local mappings_normal_mode = mappings
|
telescope.setup {
|
||||||
local mappings_insert_mode = vim.tbl_extend('force', mappings, {
|
defaults = {
|
||||||
['<c-j>'] = actions.cycle_history_next,
|
prompt_prefix = ' ❯ ',
|
||||||
['<c-k>'] = actions.cycle_history_prev,
|
selection_caret = ' ', -- Other ideas: ➔
|
||||||
})
|
multi_icon = ' ',
|
||||||
|
|
||||||
telescope.setup {
|
layout_strategy = 'flex',
|
||||||
defaults = {
|
layout_config = {
|
||||||
prompt_prefix = ' ❯ ',
|
anchor = 'center',
|
||||||
selection_caret = ' ', -- Other ideas: ➔
|
width = 0.9,
|
||||||
multi_icon = ' ',
|
height = 0.9,
|
||||||
|
|
||||||
layout_strategy = 'flex',
|
flex = {
|
||||||
layout_config = {
|
flip_columns = 130,
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
cycle_layout_list = {
|
horizontal = {
|
||||||
{ layout_strategy = 'bottom_pane', layout_config = { width = 1, height = 0.4 }, },
|
preview_width = 0.5,
|
||||||
'horizontal',
|
preview_cutoff = 130,
|
||||||
'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 = {
|
||||||
i = mappings_insert_mode,
|
n = {
|
||||||
n = mappings_normal_mode,
|
-- normal mode mappings go here
|
||||||
},
|
},
|
||||||
},
|
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' } }
|
builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", " " } }
|
||||||
end
|
end
|
||||||
end,
|
elseif sysname == "freebsd" then
|
||||||
}
|
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
|
||||||
|
|
||||||
|
local telescope = {
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
config = config,
|
||||||
}
|
}
|
||||||
|
|
||||||
local file_browser = {
|
local file_browser = {
|
||||||
'nvim-telescope/telescope-file-browser.nvim',
|
'nvim-telescope/telescope-file-browser.nvim',
|
||||||
|
|
||||||
dependencies = {
|
dependencies = { 'nvim-telescope/telescope.nvim' },
|
||||||
'nvim-telescope/telescope.nvim',
|
|
||||||
},
|
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
require('telescope').load_extension 'file_browser'
|
require('telescope').load_extension 'file_browser'
|
||||||
|
|
|
@ -1,98 +1,97 @@
|
||||||
return {
|
local config = function()
|
||||||
{
|
require('nvim-treesitter.configs').setup {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
ensure_installed = {
|
||||||
|
'bash',
|
||||||
|
'c',
|
||||||
|
'cpp',
|
||||||
|
'haskell',
|
||||||
|
'html',
|
||||||
|
'javascript',
|
||||||
|
'latex',
|
||||||
|
'lua',
|
||||||
|
'make',
|
||||||
|
'markdown',
|
||||||
|
'markdown_inline',
|
||||||
|
'python',
|
||||||
|
'query',
|
||||||
|
'toml',
|
||||||
|
'vim',
|
||||||
|
'vimdoc',
|
||||||
|
'yaml',
|
||||||
|
},
|
||||||
|
|
||||||
opts = {
|
highlight = {
|
||||||
ensure_installed = {
|
enable = true,
|
||||||
'bash',
|
disable = {
|
||||||
'c',
|
|
||||||
'cpp',
|
|
||||||
'haskell',
|
|
||||||
'html',
|
|
||||||
'javascript',
|
|
||||||
'latex',
|
|
||||||
'lua',
|
|
||||||
'make',
|
|
||||||
'markdown',
|
|
||||||
'markdown_inline',
|
|
||||||
'python',
|
|
||||||
'query',
|
|
||||||
'toml',
|
|
||||||
'vim',
|
|
||||||
'vimdoc',
|
'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)
|
incremental_selection = {
|
||||||
require('nvim-treesitter.configs').setup(opts)
|
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
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>sp', '<cmd>TSPlaygroundToggle<cr>')
|
refactor = {
|
||||||
vim.keymap.set('n', '<leader>sh', '<cmd>TSHighlightCapturesUnderCursor<cr>')
|
highlight_definitions = { enable = true },
|
||||||
vim.keymap.set('n', '<leader>sn', '<cmd>TSNodeUnderCursor<cr>')
|
highlight_current_scope = { enable = false },
|
||||||
end,
|
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
config = config,
|
||||||
},
|
},
|
||||||
|
|
||||||
'nvim-treesitter/nvim-treesitter-refactor',
|
'nvim-treesitter/nvim-treesitter-refactor',
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
return {
|
return {
|
||||||
'lukas-reineke/virt-column.nvim',
|
'lukas-reineke/virt-column.nvim',
|
||||||
|
|
||||||
opts = {
|
config = function()
|
||||||
char = '│',
|
require('virt-column').setup {
|
||||||
},
|
char = '│',
|
||||||
|
}
|
||||||
config = function(_, opts)
|
|
||||||
require('virt-column').setup(opts)
|
|
||||||
|
|
||||||
local toggle_virtual_column = function()
|
local toggle_virtual_column = function()
|
||||||
if vim.o.colorcolumn == '' then
|
if vim.o.colorcolumn == '' then
|
||||||
|
|
Loading…
Add table
Reference in a new issue