522 lines
16 KiB
Lua
522 lines
16 KiB
Lua
local M = {}
|
|
|
|
function M.colorizer()
|
|
require('colorizer').setup(
|
|
{'*'},
|
|
{
|
|
RGB = true, -- #RGB hex codes
|
|
RRGGBB = true, -- #RRGGBB hex codes
|
|
names = true, -- "Name" codes like Blue
|
|
RRGGBBAA = true, -- #RRGGBBAA hex codes
|
|
rgb_fn = true, -- CSS rgb() and rgba() functions
|
|
hsl_fn = true, -- CSS hsl() and hsla() functions
|
|
css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
|
css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
|
mode = 'background' -- Set the display mode.
|
|
})
|
|
end
|
|
|
|
-- function M.illuminate()
|
|
-- vim.g.Illuminate_delay = 500
|
|
-- vim.g.Illuminate_ftblacklist = {'alpha', 'NvimTree', 'undotree', 'packer'}
|
|
-- end
|
|
|
|
function M.org_bullets()
|
|
require('org-bullets').setup {
|
|
symbols = {'', '', '', ''}
|
|
}
|
|
end
|
|
|
|
function M.orgmode()
|
|
local c = require('themes.' .. vim.g.colors_name .. '.colors')
|
|
require('orgmode').setup {
|
|
-- General settings
|
|
org_agenda_files = {'~/Documents/Org/agenda/*'},
|
|
org_default_notes_file = '~/Documents/Org/notes.org',
|
|
org_todo_keywords = {
|
|
'TODO', 'WAIT', 'HOLD', 'IDEA', 'DONE', 'KILL', 'CANCELED',
|
|
'OKAY', 'YES', 'NO'
|
|
},
|
|
org_todo_keyword_faces = {
|
|
TODO = ':foreground ' .. c.green .. ' :weight bold',
|
|
WAIT = ':foreground ' .. c.yellow .. ' :weight bold',
|
|
HOLD = ':foreground ' .. c.yellow .. ' :weight bold',
|
|
IDEA = ':foreground ' .. c.green .. ' :weight bold :slant italic',
|
|
DONE = ':foreground ' .. c.purple .. ' :weight bold',
|
|
OKAY = ':foreground ' .. c.purple .. ' :weight bold :slant italic',
|
|
KILL = ':foreground ' .. c.red .. ' :weight bold',
|
|
CANCELED = ':foreground ' .. c.red .. ' :weight bold',
|
|
YES = ':foreground ' .. c.green .. ' :weight bold :underline on',
|
|
NO = ':foreground ' .. c.red .. ' :weight bold :underline on'
|
|
},
|
|
org_hide_emphasis_markers = true,
|
|
org_hide_leading_stars = true,
|
|
org_highlight_latex_and_related = 'entities',
|
|
|
|
-- Agenda settings
|
|
org_deadline_warning_days = 7,
|
|
org_agenda_span = 'week',
|
|
org_agenda_start_on_weekday = 7, -- Start a week in Sunday
|
|
org_agenda_min_height = 15,
|
|
|
|
-- Tags settings
|
|
org_use_tag_inheritance = false
|
|
}
|
|
|
|
require('mappings').orgmode()
|
|
end
|
|
|
|
function M.headlines()
|
|
require('headlines').setup {
|
|
markdown = {
|
|
headline_signs = false,
|
|
dash_highlight = false,
|
|
codeblock_sign = 'CodeBlock'
|
|
},
|
|
org = {
|
|
headline_signs = false,
|
|
dash_highlight = false,
|
|
codeblock_sign = 'CodeBlock'
|
|
}
|
|
}
|
|
end
|
|
|
|
function M.treesitter()
|
|
-- Additional parser for rest.nvim (*.http files)
|
|
local parser_configs = require('nvim-treesitter.parsers').get_parser_configs()
|
|
parser_configs.http = {
|
|
install_info = {
|
|
url = 'https://github.com/NTBBloodbath/tree-sitter-http',
|
|
files = {'src/parser.c'},
|
|
branch = 'main'
|
|
}
|
|
}
|
|
parser_configs.org = {
|
|
install_info = {
|
|
url = 'https://github.com/milisims/tree-sitter-org',
|
|
revision = 'main',
|
|
files = {'src/parser.c', 'src/scanner.cc'},
|
|
branch = 'master'
|
|
}
|
|
}
|
|
|
|
require('nvim-treesitter.configs').setup {
|
|
ensure_installed = 'all',
|
|
highlight = {
|
|
enable = true,
|
|
additional_vim_regex_highlighting = {'org'}
|
|
},
|
|
incremental_selection = {
|
|
enable = true,
|
|
keymaps = {
|
|
init_selection = 'gni',
|
|
node_incremental = 'gnn',
|
|
scope_incremental = 'gns',
|
|
node_decremental = 'gnm'
|
|
}
|
|
},
|
|
indent = {enable = false},
|
|
refactor = {
|
|
highlight_definitions = {enable = true},
|
|
highlight_current_scope = {enable = false},
|
|
smart_rename = {
|
|
enable = true,
|
|
keymaps = {smart_rename = 'gnr'}
|
|
},
|
|
navigation = {
|
|
enable = true,
|
|
keymaps = {
|
|
goto_definition = 'gnd',
|
|
list_definitions = 'gnD',
|
|
list_definitions_toc = 'gno',
|
|
goto_next_usage = 'gnk',
|
|
goto_previous_usage = 'gnj'
|
|
}
|
|
}
|
|
},
|
|
autotag = {
|
|
enable = true,
|
|
filetypes = {
|
|
'html', 'javascript', 'javascriptreact', 'typescript',
|
|
'typescriptreact', 'svelte', 'vue'
|
|
}
|
|
},
|
|
textobjects = {
|
|
select = {
|
|
enable = true,
|
|
lookahead = true,
|
|
keymaps = {
|
|
['af'] = '@function.outer',
|
|
['if'] = '@function.inner',
|
|
['ac'] = '@class.outer',
|
|
['ic'] = '@class.inner'
|
|
}
|
|
},
|
|
move = {
|
|
enable = true,
|
|
set_jumps = true, -- whether to set jumps in the jumplist
|
|
goto_next_start = {
|
|
[']['] = '@function.outer',
|
|
[']m'] = '@class.outer'
|
|
},
|
|
goto_next_end = {
|
|
[']]'] = '@function.outer',
|
|
[']M'] = '@class.outer'
|
|
},
|
|
goto_previous_start = {
|
|
['[['] = '@function.outer',
|
|
['[m'] = '@class.outer'
|
|
},
|
|
goto_previous_end = {
|
|
['[]'] = '@function.outer',
|
|
['[M'] = '@class.outer'
|
|
}
|
|
}
|
|
},
|
|
matchup = {enable = true},
|
|
rainbow = {
|
|
enable = true,
|
|
extended_mode = true,
|
|
max_file_lines = 1000
|
|
},
|
|
playground = {
|
|
enable = true,
|
|
disable = {},
|
|
updatetime = 25,
|
|
persist_queries = false,
|
|
keybindings = {
|
|
toggle_query_editor = 'o',
|
|
toggle_hl_groups = 'i',
|
|
toggle_injected_languages = 't',
|
|
toggle_anonymous_nodes = 'a',
|
|
toggle_language_display = 'I',
|
|
focus_language = 'f',
|
|
unfocus_language = 'F',
|
|
update = 'R',
|
|
goto_node = '<cr>',
|
|
show_help = '?'
|
|
}
|
|
},
|
|
query_linter = {
|
|
enable = true,
|
|
use_virtual_text = true,
|
|
lint_events = {'BufWrite', 'CursorHold'}
|
|
},
|
|
context_commentstring = {
|
|
enable = true,
|
|
enable_autocmd = false,
|
|
config = {
|
|
fish = '# %s',
|
|
lisp = ';; %s'
|
|
}
|
|
}
|
|
}
|
|
|
|
-- tree-sitter based folding
|
|
vim.opt.foldmethod = 'expr'
|
|
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
|
|
|
|
require('mappings').treesitter()
|
|
end
|
|
|
|
-- function M.detect_language()
|
|
-- require('detect-language').setup()
|
|
-- vim.api.nvim_command('autocmd BufNewFile * DetectLanguageBufEnable')
|
|
-- end
|
|
|
|
-- function M.spellsitter()
|
|
-- require('spellsitter').setup {
|
|
-- -- Whether enabled, can be a list of filetypes, e.g. {'python', 'lua'}
|
|
-- enable = true,
|
|
-- -- Highlight to use for bad spellings
|
|
-- hl = 'SpellBad',
|
|
-- -- Spellchecker to use. values:
|
|
-- -- * vimfn: built-in spell checker using vim.fn.spellbadword()
|
|
-- -- * ffi: built-in spell checker using the FFI to access the
|
|
-- -- internal spell_check() function
|
|
-- spellchecker = 'vimfn',
|
|
-- }
|
|
-- end
|
|
|
|
function M.indent_blankline()
|
|
require('indent_blankline').setup {
|
|
char = '│',
|
|
-- space_char_blankline = '·',
|
|
show_first_indent_level = true,
|
|
filetype_exclude = {
|
|
'startify', 'dashboard', 'alpha', 'log', 'gitcommit', 'packer', 'vimwiki',
|
|
'markdown', 'org', 'json', 'txt', 'help', 'NvimTree', 'git', 'TelescopePrompt',
|
|
'undotree', 'dotooagenda', 'fugitive',
|
|
'' -- for all buffers without a filetype
|
|
},
|
|
buftype_exclude = {'terminal', 'nofile'},
|
|
show_trailing_blankline_indent = false,
|
|
-- show_end_of_line = true,
|
|
show_current_context = true,
|
|
context_patterns = {
|
|
'class', 'function', 'method', 'block', 'list_literal', 'selector', '^if',
|
|
'^table', 'if_statement', 'while', 'for'
|
|
},
|
|
use_treesitter = true
|
|
}
|
|
|
|
-- Refresh often, since it is lazy-loaded
|
|
-- vim.api.nvim_command('autocmd CursorMoved * IndentBlanklineRefresh')
|
|
end
|
|
|
|
function M.iswap()
|
|
require('iswap').setup {
|
|
-- The keys that will be used as a selection, in order
|
|
-- ('asdfghjklqwertyuiopzxcvbnm' by default)
|
|
-- keys = 'qwertyuiop',
|
|
|
|
-- Grey out the rest of the text when making a selection
|
|
-- (enabled by default)
|
|
-- grey = 'disable',
|
|
|
|
-- Highlight group for the sniping value (asdf etc.)
|
|
-- default 'Search'
|
|
-- hl_snipe = 'ErrorMsg',
|
|
|
|
-- Highlight group for the visual selection of terms
|
|
-- default 'Visual'
|
|
-- hl_selection = 'WarningMsg',
|
|
|
|
-- Highlight group for the greyed background
|
|
-- default 'Comment'
|
|
hl_grey = 'LineNr',
|
|
|
|
-- Automatically swap with only two arguments
|
|
-- default nil
|
|
autoswap = true
|
|
}
|
|
end
|
|
|
|
function M.matchup()
|
|
vim.g.matchup_matchparen_offscreen = {method = 'popup'}
|
|
end
|
|
|
|
function M.twilight()
|
|
require('twilight').setup {
|
|
dimming = {
|
|
alpha = 0.25, -- amount of dimming
|
|
-- we try to get the foreground from the highlight groups or fallback color
|
|
color = {'Normal', '#ffffff'},
|
|
inactive = false -- when true, other windows will be fully dimmed (unless they contain the same buffer)
|
|
},
|
|
context = 10,
|
|
treesitter = true,
|
|
expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
|
|
'function',
|
|
'method',
|
|
'table',
|
|
'if_statement'
|
|
},
|
|
exclude = {'alpha', 'packer', 'NvimTree', 'qf'}
|
|
}
|
|
end
|
|
|
|
function M.zenmode()
|
|
require('zen-mode').setup {
|
|
window = {
|
|
options = {
|
|
signcolumn = 'no',
|
|
number = false,
|
|
relativenumber = false,
|
|
cursorline = false,
|
|
cursorcolumn = false,
|
|
foldcolumn = '0'
|
|
}
|
|
},
|
|
-- on_open = function()
|
|
-- vim.api.nvim_command('TSContextDisable')
|
|
-- vim.api.nvim_command('IndentBlanklineDisable')
|
|
-- end,
|
|
-- on_close = function()
|
|
-- vim.api.nvim_command('TSContextEnable')
|
|
-- vim.api.nvim_command('IndentBlanklineEnable')
|
|
-- end
|
|
}
|
|
end
|
|
|
|
function M.better_escape()
|
|
require('better_escape').setup {
|
|
mapping = {'jk', 'kj'},
|
|
timeout = vim.opt.timeoutlen:get(),
|
|
clear_empty_lines = false,
|
|
keys = '<Esc>'
|
|
}
|
|
end
|
|
|
|
function M.hop()
|
|
require('hop').setup {keys = 'etovxqpdygfblzhckisuran'}
|
|
end
|
|
|
|
function M.eft()
|
|
vim.g.eft_index_function = {all = function() return true end}
|
|
require('mappings').eft()
|
|
end
|
|
|
|
function M.dial()
|
|
local dial = require('dial')
|
|
|
|
-- Custom augends
|
|
dial.augends['custom#boolean'] = dial.common.enum_cyclic{
|
|
name = 'boolean',
|
|
strlist = {'true', 'false'}
|
|
}
|
|
dial.augends['custom#boolean2'] = dial.common.enum_cyclic{
|
|
name = 'boolean',
|
|
strlist = {'True', 'False'}
|
|
}
|
|
|
|
dial.config.searchlist.normal = {
|
|
'number#decimal#int',
|
|
'number#decimal#fixed#zero',
|
|
'number#hex',
|
|
'number#binary',
|
|
'date#[%Y/%m/%d]',
|
|
'date#[%m/%d]',
|
|
'date#[%Y-%m-%d]',
|
|
'date#[%H:%M:%S]',
|
|
'date#[%H:%M]',
|
|
'date#[%jA]',
|
|
'color#hex',
|
|
'markup#markdown#header',
|
|
'custom#boolean',
|
|
'custom#boolean2'
|
|
}
|
|
dial.config.searchlist.visual = {
|
|
'number#decimal#int',
|
|
'number#decimal#fixed#zero',
|
|
'number#hex',
|
|
'number#binary',
|
|
'date#[%Y/%m/%d]',
|
|
'date#[%m/%d]',
|
|
'date#[%Y-%m-%d]',
|
|
'date#[%H:%M:%S]',
|
|
'date#[%H:%M]',
|
|
'date#[%jA]',
|
|
'char#alph#small#word',
|
|
'char#alph#capital#word',
|
|
'color#hex'
|
|
}
|
|
|
|
require('mappings').dial()
|
|
end
|
|
|
|
function M.table_mode()
|
|
vim.g.table_mode_disable_mappings = 1
|
|
vim.g.table_mode_disable_tableize_mappings = 1
|
|
vim.g.table_mode_map_prefix = '<leader>et'
|
|
vim.g.table_mode_toggle_map = ''
|
|
end
|
|
|
|
function M.comment()
|
|
require('Comment').setup {
|
|
padding = true, -- add a ' ' between comment and the line
|
|
sticky = true, -- whether the cursor should stay at its position
|
|
ignore = '^$', -- ignore empty lines
|
|
mappings = {
|
|
basic = true, -- 'gcc', 'gcb', 'gc[count]{motion}', 'gb[count]{motion}'
|
|
extra = true, -- 'gco', 'gcO', 'gcA'
|
|
extended = false -- 'g>', 'g>[count]{motion}', 'g<[count]{motion}'
|
|
},
|
|
toggle = { -- toggle mapping in NORMAL + VISUAL mode
|
|
line = 'gcc',
|
|
block = 'gbc'
|
|
},
|
|
opleader = { -- operator-pending mapping in NORMAL + VISUAL mode
|
|
line = 'gc',
|
|
block = 'gb'
|
|
},
|
|
pre_hook = function(ctx)
|
|
require('ts_context_commentstring.internal').update_commentstring()
|
|
end,
|
|
post_hook = nil
|
|
}
|
|
end
|
|
|
|
function M.range_highlight()
|
|
require('range-highlight').setup()
|
|
end
|
|
|
|
function M.neogen()
|
|
require('neogen').setup {
|
|
enabled = true,
|
|
input_after_comment = true
|
|
}
|
|
require('mappings').neogen()
|
|
end
|
|
|
|
function M.project()
|
|
require('project_nvim').setup {
|
|
manual_mode = false,
|
|
detection_methods = {'lsp', 'pattern'},
|
|
patterns = {'.git', '_darcs', '.hg', '.bzr', '.svn', 'Makefile', 'package.json', '*.pro', 'Dockerfile', '>Code'},
|
|
show_hidden = true,
|
|
silent_chdir = true,
|
|
datapath = vim.fn.stdpath('data')
|
|
}
|
|
|
|
-- cd on local window changes with 'lcd' (more eager)
|
|
-- see https://github.com/ahmedkhalf/project.nvim/issues/23
|
|
-- _G.set_window_project_dir = function()
|
|
-- local root, _ = require('project_nvim.project').get_project_root()
|
|
-- if root then
|
|
-- vim.api.nvim_command('lcd ' .. root)
|
|
-- end
|
|
-- end
|
|
-- vim.api.nvim_command('autocmd BufEnter * lua set_window_project_dir()')
|
|
end
|
|
|
|
function M.gitlinker()
|
|
require('gitlinker').setup {
|
|
opts = {
|
|
remote = nil, -- force the use of a specific remote
|
|
-- adds current line nr in the url for normal mode
|
|
add_current_line_on_normal_mode = true,
|
|
-- callback for what to do with the url
|
|
action_callback = require('gitlinker.actions').copy_to_clipboard,
|
|
-- print the url after performing the action
|
|
print_url = true,
|
|
},
|
|
callbacks = {
|
|
['git.folliehiyuki.com'] = require('gitlinker.hosts').get_gitea_type_url,
|
|
['git.disroot.org'] = require('gitlinker.hosts').get_gitea_type_url,
|
|
['gitlab.alpinelinux.org'] = require('gitlinker.hosts').get_gitlab_type_url
|
|
},
|
|
-- default mapping to call url generation with action_callback
|
|
mappings = '<leader>gy'
|
|
}
|
|
|
|
require('mappings').gitlinker()
|
|
end
|
|
|
|
function M.filetype()
|
|
require('filetype').setup {
|
|
overrides = {
|
|
extensions = {
|
|
md = 'markdown',
|
|
mkd = 'markdown',
|
|
toml = 'toml',
|
|
rasi = 'css',
|
|
vifm = 'vim',
|
|
log = 'log',
|
|
LO = 'log'
|
|
},
|
|
literal = {
|
|
vifmrc = 'vim'
|
|
},
|
|
complex = {
|
|
['*_log'] = 'log',
|
|
['G*_LOG'] = 'log',
|
|
['.*waybar/config'] = 'jsonc',
|
|
['.*lf/lfrc'] = 'sh'
|
|
}
|
|
}
|
|
}
|
|
end
|
|
|
|
return M
|