neovim: treesitter conceal for lua
a21a2de0f51168b36fa17f870bdd45ccb7746ed4
Oliver Jan Krylow <olver@bugabinga.net> ·
unsigned
- Parent 1: f63097f689fb
bugabingas dorkfiles
a21a2de0f51168b36fa17f870bdd45ccb7746ed4
Oliver Jan Krylow <olver@bugabinga.net> ·
unsigned
+1000 / −487 text lines
new file mode 100644+12 / −0 text lines
(("local" @keyword) (#set! conceal "⋅"))(("function" @keyword.function) (#set! conceal "ϝ"))(("end" @keyword.function) (#set! conceal "∎"))(("return" @keyword.return) (#set! conceal "↳"))(("then" @conditional) (#set! conceal "⟶"))((dot_index_expression table: (identifier) @variable (#eq? @variable "vim")) (#set! conceal ""))((function_call name: (identifier) @function (#eq? @function "require")) (#set! conceal "")); ((function_call name: (identifier) @function (#eq? @function "want")) (#set! conceal "ω")); ((local_declaration name: (identifier) @variable (#eq? @variable "want") (#set! conceal "ω"))+4 / −0 text lines
+12 / −13 text lines
-- TODO: DAP-- TODO: put all keybinds into facade-- TODO: preview multimedia with telescope-- TODO: icon facade: icon.get("name")-- TODO: use nvim-specific lsp only in neovim config-- TODO: is it possible to cache LSP init per project?-- TODO: stop treesitter error highlight while typing-- TODO: load plugins/init.lua and sync on write. reload init.lua?-- TODO: use nvim-specific lsp only in neovim config-- TODO: steal filetype settings from shark, astrovim, lunarvim etc-- TODO: is it possible to cache LSP init per project?-- TODO: DAP-- TODO: fix cursor flicker when openinig neotree and other windows stuff in lsp buffers+8 / −0 text lines
new file mode 100644+125 / −0 text lines
-- TODO: once the colortheme is lushified, use it as a source of colors herelocal want = require 'bugabinga.std.want'want { 'nvim-web-devicons' } (function(devicons) devicons.setup { -- return a default icon when icon query cannot be mapped to existing icon default = true, override = { -- -- FILE sh = { icon = '', color = '#1DC123', cterm_color = '59', name = 'Sh' }, toml = { icon = '', color = '#e24329', cterm_color = '59', name = 'Toml' }, justfile = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' }, Justfile = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' }, ['.justfile'] = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' }, ['.Justfile'] = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' }, ['.gitattributes'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitAttributes' }, ['.gitconfig'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitConfig' }, ['.gitignore'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitIgnore' }, ['.gitlab-ci.yml'] = { icon = '', color = '#e24329', cterm_color = '166', name = 'GitlabCI' }, ['.gitmodules'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitModules' }, ['diff'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'Diff' }, -- -- KIND Text = { icon = '', color = '#949494', cterm_color = '59', name = 'TextSymbol' }, Method = { icon = 'm', color = '#949494', cterm_color = '59', name = 'MethodSymbol' }, Function = { icon = '', color = '#949494', cterm_color = '59', name = 'FunctionSymbol' }, Constructor = { icon = '', color = '#949494', cterm_color = '59', name = 'ConstructorSymbol' }, Field = { icon = '', color = '#949494', cterm_color = '59', name = 'FieldSymbol' }, Variable = { icon = '', color = '#949494', cterm_color = '59', name = 'VariableSymbol' }, Class = { icon = '', color = '#949494', cterm_color = '59', name = 'ClassSymbol' }, Interface = { icon = '', color = '#949494', cterm_color = '59', name = 'InterfaceSymbol' }, Module = { icon = '', color = '#949494', cterm_color = '59', name = 'ModuleSymbol' }, Property = { icon = '', color = '#949494', cterm_color = '59', name = 'PropertySymbol' }, Unit = { icon = '', color = '#949494', cterm_color = '59', name = 'UnitSymbol' }, Value = { icon = '', color = '#949494', cterm_color = '59', name = 'ValueSymbol' }, Enum = { icon = '', color = '#949494', cterm_color = '59', name = 'EnumSymbol' }, Keyword = { icon = '', color = '#949494', cterm_color = '59', name = 'KeywordSymbol' }, Snippet = { icon = '', color = '#949494', cterm_color = '59', name = 'SnippetSymbol' }, Color = { icon = '', color = '#949494', cterm_color = '59', name = 'ColorSymbol' }, File = { icon = '', color = '#949494', cterm_color = '59', name = 'FileSymbol' }, Reference = { icon = '', color = '#949494', cterm_color = '59', name = 'ReferenceSymbol' }, Folder = { icon = '', color = '#949494', cterm_color = '59', name = 'FolderSymbol' }, EnumMember = { icon = '', color = '#949494', cterm_color = '59', name = 'EnumMemberSymbol' }, Constant = { icon = '', color = '#949494', cterm_color = '59', name = 'ConstantSymbol' }, Struct = { icon = '', color = '#949494', cterm_color = '59', name = 'StructSymbol' }, Event = { icon = '', color = '#949494', cterm_color = '59', name = 'EventSymbol' }, Operator = { icon = '', color = '#949494', cterm_color = '59', name = 'OperatorSymbol' }, TypeParameter = { icon = '', color = '#949494', cterm_color = '59', name = 'TypeParameterSymbol' }, -- -- TYPE Array = { icon = '', color = '#949494', cterm_color = '59', name = 'ArraySymbol' }, Number = { icon = '', color = '#949494', cterm_color = '59', name = 'NumberSymbol' }, String = { icon = '', color = '#949494', cterm_color = '59', name = 'StringSymbol' }, Boolean = { icon = '蘒', color = '#949494', cterm_color = '59', name = 'BooleanSymbol' }, Object = { icon = '', color = '#949494', cterm_color = '59', name = 'ObjectSymbol' }, -- -- DOCUMENTS Files = { icon = '', color = '#949494', cterm_color = '59', name = 'FilesSymbol' }, OpenFolder = { icon = '', color = '#949494', cterm_color = '59', name = 'OpenFolderSymbol' }, EmptyFolder = { icon = '', color = '#949494', cterm_color = '59', name = 'EmptyFolderSymbol' }, -- -- VCS VcsAdded = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsAddedSymbol' }, VcsModified = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsModifiedSymbol' }, VcsRemoved = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRemovedSymbol' }, VcsIgnored = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsIgnoredSymbol' }, VcsRenamed = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRenamedSymbol' }, VcsDiff = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsDiffSymbol' }, VcsRepo = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRepoSymbol' }, VcsUntracked = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsUntrackedSymbol' }, VcsUnstaged = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsUnstagedSymbol' }, VcsStaged = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsStagedSymbol' }, VcsConflicted = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsConflictedSymbol' }, -- --UI ArrowClosed = { icon = '', color = '#949494', cterm_color = '59', name = 'ArrowClosedSymbol' }, ArrowOpen = { icon = '', color = '#949494', cterm_color = '59', name = 'ArrowOpenSymbol' }, Lock = { icon = '', color = '#949494', cterm_color = '59', name = 'LockSymbol' }, Circle = { icon = '', color = '#949494', cterm_color = '59', name = 'CircleSymbol' }, BigCircle = { icon = '', color = '#949494', cterm_color = '59', name = 'BigCircleSymbol' }, BigUnfilledCircle = { icon = '', color = '#949494', cterm_color = '59', name = 'BigUnfilledCircleSymbol' }, Close = { icon = '', color = '#949494', cterm_color = '59', name = 'CloseSymbol' }, NewFile = { icon = '', color = '#949494', cterm_color = '59', name = 'NewFileSymbol' }, Search = { icon = '', color = '#949494', cterm_color = '59', name = 'SearchSymbol' }, Lightbulb = { icon = '', color = '#949494', cterm_color = '59', name = 'LightbulbSymbol' }, Project = { icon = '', color = '#949494', cterm_color = '59', name = 'ProjectSymbol' }, Dashboard = { icon = '', color = '#949494', cterm_color = '59', name = 'DashboardSymbol' }, History = { icon = '', color = '#949494', cterm_color = '59', name = 'HistorySymbol' }, Comment = { icon = '', color = '#949494', cterm_color = '59', name = 'CommentSymbol' }, Bug = { icon = '', color = '#949494', cterm_color = '59', name = 'BugSymbol' }, Code = { icon = '', color = '#949494', cterm_color = '59', name = 'CodeSymbol' }, Telescope = { icon = '', color = '#949494', cterm_color = '59', name = 'TelescopeSymbol' }, Gear = { icon = '', color = '#949494', cterm_color = '59', name = 'GearSymbol' }, Package = { icon = '', color = '#949494', cterm_color = '59', name = 'PackageSymbol' }, List = { icon = '', color = '#949494', cterm_color = '59', name = 'ListSymbol' }, SignIn = { icon = '', color = '#949494', cterm_color = '59', name = 'SignInSymbol' }, SignOut = { icon = '', color = '#949494', cterm_color = '59', name = 'SignOutSymbol' }, Check = { icon = '', color = '#949494', cterm_color = '59', name = 'CheckSymbol' }, Fire = { icon = '', color = '#949494', cterm_color = '59', name = 'FireSymbol' }, Note = { icon = '', color = '#949494', cterm_color = '59', name = 'NoteSymbol' }, BookMark = { icon = '', color = '#949494', cterm_color = '59', name = 'BookMarkSymbol' }, Pencil = { icon = '', color = '#949494', cterm_color = '59', name = 'PencilSymbol' }, ChevronRight = { icon = '', color = '#949494', cterm_color = '59', name = 'ChevronRightSymbol' }, Table = { icon = '', color = '#949494', cterm_color = '59', name = 'TableSymbol' }, Calendar = { icon = '', color = '#949494', cterm_color = '59', name = 'CalendarSymbol' }, CloudDownload = { icon = '', color = '#949494', cterm_color = '59', name = 'CloudDownloadSymbol' }, -- -- DIAGNOSTICS Error = { icon = '', color = '#949494', cterm_color = '59', name = 'ErrorSymbol' }, Warning = { icon = '', color = '#949494', cterm_color = '59', name = 'WarningSymbol' }, Information = { icon = '', color = '#949494', cterm_color = '59', name = 'InformationSymbol' }, Question = { icon = '', color = '#949494', cterm_color = '59', name = 'QuestionSymbol' }, Hint = { icon = '', color = '#949494', cterm_color = '59', name = 'HintSymbol' }, -- -- MISCELLANEOUS Robot = { icon = 'ﮧ', color = '#949494', cterm_color = '59', name = 'RobotSymbol' }, Squirrel = { icon = '', color = '#949494', cterm_color = '59', name = 'SquirrelSymbol' }, Tag = { icon = '', color = '#949494', cterm_color = '59', name = 'TagSymbol' }, Watch = { icon = '', color = '#949494', cterm_color = '59', name = 'WatchSymbol' }, }, } -- devicons will return some default icon, when an icon name could not be mapped. -- in order to quickly notice these cases and debug them, set a noticeable icon as default. devicons.set_default_icon('ﴫ', '#ff00ff')end)new file mode 100644+153 / −0 text lines
-- the topic 'diagnotics' was refactored out of LSP into its own thing some time-- ago. that is why it gets its own section in this config now, but right now,-- those settings overlap with lsp-zero.local auto = require 'bugabinga.std.auto'local map = require 'bugabinga.std.keymap'local icon = require 'bugabinga.std.icon'local diagnostic = vim.diagnosticlocal diagnostic_format = function(context) local message = context.message local severity = context.severity local symbol = '' if severity == diagnostic.severity.ERROR then symbol = icon 'Error' elseif severity == diagnostic.severity.WARN then symbol = icon 'Warning' elseif severity == diagnostic.severity.INFO then symbol = icon 'Information' elseif severity == diagnostic.severity.HINT then symbol = icon 'Hint' end return string.format('%s | %s', symbol, message)endlocal prefix_format = function(context, index, total) local source = context.source local severity = context.severity local symbol = '' if severity == diagnostic.severity.ERROR then symbol = icon 'Error' elseif severity == diagnostic.severity.WARN then symbol = icon 'Warning' elseif severity == diagnostic.severity.INFO then symbol = icon 'Information' elseif severity == diagnostic.severity.HINT then symbol = icon 'Hint' end return string.format('%s/%s %s %s ', index, total, source, symbol)enddiagnostic.config { underline = { severity = diagnostic.severity.ERROR, }, virtual_text = { severity = diagnostic.severity.HINT, source = false, spacing = 0, prefix = '', format = diagnostic_format, }, float = { focusable = false, style = 'minimal', border = 'rounded', source = false, header = '', prefix = prefix_format, }, update_in_insert = false, signs = true, severity_sort = true,}local sign = function(options) vim.fn.sign_define(options.name, { texthl = options.name, text = options.text, numhl = '', })endsign { name = 'DiagnosticSignError', text = icon 'Error' }sign { name = 'DiagnosticSignWarn', text = icon 'Warning' }sign { name = 'DiagnosticSignHint', text = icon 'Hint' }sign { name = 'DiagnosticSignInfo', text = icon 'Information' }auto 'hide_diagnostics' { description = 'Hide diagnostics by default', events = { 'BufReadPre' }, pattern = '*', command = function() diagnostic.disable(0) end,}local saved_cursor_highlight = vim.api.nvim_get_hl_by_name('Cursor', true)-- TODO: get colors from themelocal noticeable = { foreground = '#ffffff', background = '#ff0000'}auto 'cursor_attention_if_diagnostics' { description = 'Make cursor very noticeable, if diagnostics are present', events = 'DiagnosticChanged', pattern = '*', command = function() local diagnostic_number = #vim.diagnostic.get(0,{severity = vim.diagnostic.severity.ERROR}) if diagnostic_number > 0 then vim.api.nvim_set_hl(0, 'Cursor', noticeable) else vim.api.nvim_set_hl(0, 'Cursor', saved_cursor_highlight) end end,}map { description = 'Enable diagnostics', category = map.CATEGORY.PROBLEMS, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.P, command = function() diagnostic.enable(0) end,}map { description = 'Disable diagnostics', category = map.CATEGORY.PROBLEMS, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.P .. map.KEY.P, command = function() diagnostic.disable(0) end,}map { description = 'Show diagnostics in float window', category = map.CATEGORY.PROBLEMS, mode = map.MODE.NORMAL, keys = map.KEY.F6, command = function() diagnostic.enable(0) diagnostic.open_float() end,}map { description = 'Go to previous diagnostic', category = map.CATEGORY.PROBLEMS, mode = map.MODE.NORMAL, keys = map.KEY.F7, command = function() diagnostic.enable(0) diagnostic.goto_prev() end,}map { description = 'Go to next diagnostic', category = map.CATEGORY.PROBLEMS, mode = map.MODE.NORMAL, keys = map.KEY.F8, command = function() diagnostic.enable(0) diagnostic.goto_next() end,}+29 / −31 text lines
} (function(picker, tree) command = fmt.cmd'Neotree filesystem reveal right toggle', command = fmt.cmd 'Neotree filesystem reveal right toggle', command = fmt.cmd'Neotree buffers reveal float toggle', command = fmt.cmd 'Neotree buffers reveal float toggle', command = fmt.cmd'Neotree git_status reveal current toggle', command = fmt.cmd 'Neotree git_status reveal current toggle',+69 / −4 text lines
want { 'gitsigns' }(function(gitsigns) -- FIXME use keymap facade -- FIXME integrate into null-ls gitsigns.setup()want { 'gitsigns' } (function(gitsigns) map { description = 'toogle git status line highlight', category = map.CATEGORY.VERSION_CONTROL, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.V .. map.KEY.L, command = fmt.cmd'gitsigns toggle_linehl', } map { description = 'toogle git status signs', category = map.CATEGORY.VERSION_CONTROL, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.V .. map.KEY.S, command = fmt.cmd'gitsigns toggle_signs', } map { description = 'Toogle Git Blame Line', category = map.CATEGORY.VERSION_CONTROL, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.V .. map.KEY.B, command = fmt.cmd'Gitsigns toggle_current_line_blame', } gitsigns.setup { signs = { add = { hl = 'GitSignsAdd', text = '│', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn' }, change = { hl = 'GitSignsChange', text = '│', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' }, delete = { hl = 'GitSignsDelete', text = '_', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' }, topdelete = { hl = 'GitSignsDelete', text = '‾', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' }, changedelete = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' }, }, signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` numhl = false, -- Toggle with `:Gitsigns toggle_numhl` linehl = false, -- Toggle with `:Gitsigns toggle_linehl` word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` diff_opts = { internal = true, }, watch_gitdir = { interval = 1000, follow_files = true, }, attach_to_untracked = true, current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` current_line_blame_opts = { virt_text = true, virt_text_pos = 'right_align', -- 'eol' | 'overlay' | 'right_align' delay = 866, ignore_whitespace = true, }, current_line_blame_formatter = '<author>, <author_time:%d/%m/%Y> - <summary>', sign_priority = 6, update_debounce = 100, status_formatter = nil, -- Use default max_file_length = 40000, preview_config = { -- Options passed to nvim_open_win border = 'rounded', style = 'minimal', relative = 'cursor', row = 0, col = 1, }, yadm = { enable = false, }, }deleted file mode 100644+0 / −125 text lines
-- TODO: once the colortheme is lushified, use it as a source of colors herelocal want = require 'bugabinga.std.want'want { 'nvim-web-devicons' } (function(devicons) devicons.setup { -- return a default icon when icon query cannot be mapped to existing icon default = true, override = { -- -- FILE sh = { icon = '', color = '#1DC123', cterm_color = '59', name = 'Sh' }, toml = { icon = '', color = '#e24329', cterm_color = '59', name = 'Toml' }, justfile = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' }, Justfile = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' }, ['.justfile'] = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' }, ['.Justfile'] = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' }, ['.gitattributes'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitAttributes' }, ['.gitconfig'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitConfig' }, ['.gitignore'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitIgnore' }, ['.gitlab-ci.yml'] = { icon = '', color = '#e24329', cterm_color = '166', name = 'GitlabCI' }, ['.gitmodules'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitModules' }, ['diff'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'Diff' }, -- -- KIND Text = { icon = '', color = '#949494', cterm_color = '59', name = 'TextSymbol' }, Method = { icon = 'm', color = '#949494', cterm_color = '59', name = 'MethodSymbol' }, Function = { icon = '', color = '#949494', cterm_color = '59', name = 'FunctionSymbol' }, Constructor = { icon = '', color = '#949494', cterm_color = '59', name = 'ConstructorSymbol' }, Field = { icon = '', color = '#949494', cterm_color = '59', name = 'FieldSymbol' }, Variable = { icon = '', color = '#949494', cterm_color = '59', name = 'VariableSymbol' }, Class = { icon = '', color = '#949494', cterm_color = '59', name = 'ClassSymbol' }, Interface = { icon = '', color = '#949494', cterm_color = '59', name = 'InterfaceSymbol' }, Module = { icon = '', color = '#949494', cterm_color = '59', name = 'ModuleSymbol' }, Property = { icon = '', color = '#949494', cterm_color = '59', name = 'PropertySymbol' }, Unit = { icon = '', color = '#949494', cterm_color = '59', name = 'UnitSymbol' }, Value = { icon = '', color = '#949494', cterm_color = '59', name = 'ValueSymbol' }, Enum = { icon = '', color = '#949494', cterm_color = '59', name = 'EnumSymbol' }, Keyword = { icon = '', color = '#949494', cterm_color = '59', name = 'KeywordSymbol' }, Snippet = { icon = '', color = '#949494', cterm_color = '59', name = 'SnippetSymbol' }, Color = { icon = '', color = '#949494', cterm_color = '59', name = 'ColorSymbol' }, File = { icon = '', color = '#949494', cterm_color = '59', name = 'FileSymbol' }, Reference = { icon = '', color = '#949494', cterm_color = '59', name = 'ReferenceSymbol' }, Folder = { icon = '', color = '#949494', cterm_color = '59', name = 'FolderSymbol' }, EnumMember = { icon = '', color = '#949494', cterm_color = '59', name = 'EnumMemberSymbol' }, Constant = { icon = '', color = '#949494', cterm_color = '59', name = 'ConstantSymbol' }, Struct = { icon = '', color = '#949494', cterm_color = '59', name = 'StructSymbol' }, Event = { icon = '', color = '#949494', cterm_color = '59', name = 'EventSymbol' }, Operator = { icon = '', color = '#949494', cterm_color = '59', name = 'OperatorSymbol' }, TypeParameter = { icon = '', color = '#949494', cterm_color = '59', name = 'TypeParameterSymbol' }, -- -- TYPE Array = { icon = '', color = '#949494', cterm_color = '59', name = 'ArraySymbol' }, Number = { icon = '', color = '#949494', cterm_color = '59', name = 'NumberSymbol' }, String = { icon = '', color = '#949494', cterm_color = '59', name = 'StringSymbol' }, Boolean = { icon = '蘒', color = '#949494', cterm_color = '59', name = 'BooleanSymbol' }, Object = { icon = '', color = '#949494', cterm_color = '59', name = 'ObjectSymbol' }, -- -- DOCUMENTS Files = { icon = '', color = '#949494', cterm_color = '59', name = 'FilesSymbol' }, OpenFolder = { icon = '', color = '#949494', cterm_color = '59', name = 'OpenFolderSymbol' }, EmptyFolder = { icon = '', color = '#949494', cterm_color = '59', name = 'EmptyFolderSymbol' }, -- -- VCS VcsAdded = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsAddedSymbol' }, VcsModified = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsModifiedSymbol' }, VcsRemoved = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRemovedSymbol' }, VcsIgnored = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsIgnoredSymbol' }, VcsRenamed = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRenamedSymbol' }, VcsDiff = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsDiffSymbol' }, VcsRepo = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRepoSymbol' }, VcsUntracked = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsUntrackedSymbol' }, VcsUnstaged = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsUnstagedSymbol' }, VcsStaged = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsStagedSymbol' }, VcsConflicted = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsConflictedSymbol' }, -- --UI ArrowClosed = { icon = '', color = '#949494', cterm_color = '59', name = 'ArrowClosedSymbol' }, ArrowOpen = { icon = '', color = '#949494', cterm_color = '59', name = 'ArrowOpenSymbol' }, Lock = { icon = '', color = '#949494', cterm_color = '59', name = 'LockSymbol' }, Circle = { icon = '', color = '#949494', cterm_color = '59', name = 'CircleSymbol' }, BigCircle = { icon = '', color = '#949494', cterm_color = '59', name = 'BigCircleSymbol' }, BigUnfilledCircle = { icon = '', color = '#949494', cterm_color = '59', name = 'BigUnfilledCircleSymbol' }, Close = { icon = '', color = '#949494', cterm_color = '59', name = 'CloseSymbol' }, NewFile = { icon = '', color = '#949494', cterm_color = '59', name = 'NewFileSymbol' }, Search = { icon = '', color = '#949494', cterm_color = '59', name = 'SearchSymbol' }, Lightbulb = { icon = '', color = '#949494', cterm_color = '59', name = 'LightbulbSymbol' }, Project = { icon = '', color = '#949494', cterm_color = '59', name = 'ProjectSymbol' }, Dashboard = { icon = '', color = '#949494', cterm_color = '59', name = 'DashboardSymbol' }, History = { icon = '', color = '#949494', cterm_color = '59', name = 'HistorySymbol' }, Comment = { icon = '', color = '#949494', cterm_color = '59', name = 'CommentSymbol' }, Bug = { icon = '', color = '#949494', cterm_color = '59', name = 'BugSymbol' }, Code = { icon = '', color = '#949494', cterm_color = '59', name = 'CodeSymbol' }, Telescope = { icon = '', color = '#949494', cterm_color = '59', name = 'TelescopeSymbol' }, Gear = { icon = '', color = '#949494', cterm_color = '59', name = 'GearSymbol' }, Package = { icon = '', color = '#949494', cterm_color = '59', name = 'PackageSymbol' }, List = { icon = '', color = '#949494', cterm_color = '59', name = 'ListSymbol' }, SignIn = { icon = '', color = '#949494', cterm_color = '59', name = 'SignInSymbol' }, SignOut = { icon = '', color = '#949494', cterm_color = '59', name = 'SignOutSymbol' }, Check = { icon = '', color = '#949494', cterm_color = '59', name = 'CheckSymbol' }, Fire = { icon = '', color = '#949494', cterm_color = '59', name = 'FireSymbol' }, Note = { icon = '', color = '#949494', cterm_color = '59', name = 'NoteSymbol' }, BookMark = { icon = '', color = '#949494', cterm_color = '59', name = 'BookMarkSymbol' }, Pencil = { icon = '', color = '#949494', cterm_color = '59', name = 'PencilSymbol' }, ChevronRight = { icon = '', color = '#949494', cterm_color = '59', name = 'ChevronRightSymbol' }, Table = { icon = '', color = '#949494', cterm_color = '59', name = 'TableSymbol' }, Calendar = { icon = '', color = '#949494', cterm_color = '59', name = 'CalendarSymbol' }, CloudDownload = { icon = '', color = '#949494', cterm_color = '59', name = 'CloudDownloadSymbol' }, -- -- DIAGNOSTICS Error = { icon = '', color = '#949494', cterm_color = '59', name = 'ErrorSymbol' }, Warning = { icon = '', color = '#949494', cterm_color = '59', name = 'WarningSymbol' }, Information = { icon = '', color = '#949494', cterm_color = '59', name = 'InformationSymbol' }, Question = { icon = '', color = '#949494', cterm_color = '59', name = 'QuestionSymbol' }, Hint = { icon = '', color = '#949494', cterm_color = '59', name = 'HintSymbol' }, -- -- MISCELLANEOUS Robot = { icon = 'ﮧ', color = '#949494', cterm_color = '59', name = 'RobotSymbol' }, Squirrel = { icon = '', color = '#949494', cterm_color = '59', name = 'SquirrelSymbol' }, Tag = { icon = '', color = '#949494', cterm_color = '59', name = 'TagSymbol' }, Watch = { icon = '', color = '#949494', cterm_color = '59', name = 'WatchSymbol' }, }, } -- devicons will return some default icon, when an icon name could not be mapped. -- in order to quickly notice these cases and debug them, set a noticeable icon as default. devicons.set_default_icon('ﴫ', '#ff00ff')end)+286 / −105 text lines
zero.preset 'recommended' -- Format on Save when any LSP supports it. local auto = require 'bugabinga.std.auto' local null_opts = zero.build_options('null-ls', { on_attach = function(client) if client.server_capabilities.documentFormattingProvider then auto 'format_buffer_on_write' { description = 'Format the current buffer before writing.', events = 'BufWritePre', pattern = '<buffer>', callback = function(context) vim.lsp.buf.format() vim.notify('Formatted ' .. context.file) end, } end end, }) local null_opts = zero.build_options 'null-ls' -- run diagnostics on save local diagnostics_on_save = { method = null_ls.methods.DIAGNOSTICS_ON_SAVE } null_ls.setup { on_attach = null_opts.on_attach, sources = { formatting.black.with { extra_args = { '--fast' } }, formatting.stylua, formatting.clang_format, formatting.codespell, formatting.jq, formatting.protolint, formatting.shellharden, formatting.shfmt, formatting.taplo, -- run diagnostics on save local diagnostics_on_save = { method = null_ls.methods.DIAGNOSTICS_ON_SAVE } null_ls.setup { on_attach = null_opts.on_attach, sources = { formatting.stylua, formatting.clang_format, formatting.codespell, formatting.jq, formatting.protolint, formatting.shellharden, formatting.shfmt, formatting.taplo, diagnostics.actionlint.with(diagnostics_on_save), diagnostics.checkmake.with(diagnostics_on_save), diagnostics.codespell.with(diagnostics_on_save), diagnostics.editorconfig_checker.with(diagnostics_on_save).with { command = 'editorconfig-checker' }, diagnostics.gitlint.with(diagnostics_on_save), diagnostics.protoc_gen_lint.with(diagnostics_on_save), diagnostics.protolint.with(diagnostics_on_save), diagnostics.selene.with(diagnostics_on_save).with { -- null-ls determines the root in a too simplistic manner. -- since my neovim configuration live inside my dotfiles, the dotfiles root -- was taken. but i want the neovim config folder as root. cwd = function(parameters) local project = require 'bugabinga.std.project' local root = project.determine_project_root({ name = 'selene.toml', weight = 10 }, parameters.root) return root or parameters.root end, }, diagnostics.shellcheck.with(diagnostics_on_save), diagnostics.tidy.with(diagnostics_on_save), diagnostics.actionlint.with(diagnostics_on_save), diagnostics.checkmake.with(diagnostics_on_save), diagnostics.codespell.with(diagnostics_on_save), diagnostics.editorconfig_checker.with(diagnostics_on_save).with { command = 'editorconfig-checker' }, diagnostics.gitlint.with(diagnostics_on_save), diagnostics.protoc_gen_lint.with(diagnostics_on_save), diagnostics.protolint.with(diagnostics_on_save), diagnostics.selene.with(diagnostics_on_save).with { -- null-ls determines the root in a too simplistic manner. -- since my neovim configuration live inside my dotfiles, the dotfiles root -- was taken. but i want the neovim config folder as root. cwd = function(parameters) local root = project.determine_project_root({ name = 'selene.toml', weight = 10 }, parameters.root) return root or parameters.root end, }, diagnostics.shellcheck.with(diagnostics_on_save), diagnostics.tidy.with(diagnostics_on_save), zero.on_attach(function(client, buffer_number) if client.name ~= 'null-ls' and not vim.b.lsp_attached then navic.attach(client, buffer_number) lsp_status.on_attach(client, buffer_number) end end)local function setup_keybinds_and_actions(client, buffer_number) -- TODO: make format changed lines command local capabilities = client.resolved_capabilities if capabilities.document_formatting then map { description = 'Format buffer using LSP', category = map.CATEGORY.EDITING, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.F, command = function() vim.lsp.buf.format { bufnr = buffer_number } vim.notify('Formatted ' .. vim.api.nvim_buf_get_name(buffer_number)) end, } end if capabilities.document_range_formatting then map { description = 'Format range using LSP', category = map.CATEGORY.EDITING, mode = map.MODE.VISUAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.F, command = function() vim.lsp.buf.range_formatting { bufnr = buffer_number } vim.notify('Formatted range in ' .. vim.api.nvim_buf_get_name(buffer_number)) end, } end --TODO: change some of these commands to telescoped versions if capabilities.hover then map { description = 'Show Hover', category = map.CATEGORY.VIEW, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.K, command = function() vim.lsp.buf.hover() end, } end if capabilities.goto_definition then map { description = 'Go to Definition', category = map.CATEGORY.NAVIGATION, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.D, command = function() vim.lsp.buf.definition() end, } end if capabilities.declaration then map { description = 'Go to Declaration', category = map.CATEGORY.NAVIGATION, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.D .. map.KEY.D, command = function() vim.lsp.buf.declaration() end, } end if capabilities.implementation then map { description = 'Go to Implementation', category = map.CATEGORY.NAVIGATION, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.I, command = function() vim.lsp.buf.implementation() end, } end if capabilities.type_definition then map { description = 'Go to Type Definition', category = map.CATEGORY.NAVIGATION, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.T, command = function() vim.lsp.buf.type_definition() end, } end if capabilities.find_references then map { description = 'Go to References', category = map.CATEGORY.NAVIGATION, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.R, command = function() vim.lsp.buf.references() end, } end if capabilities.call_hierarchy then map { description = 'Go to Incoming Call', category = map.CATEGORY.NAVIGATION, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.C, command = function() vim.lsp.buf.incoming_calls() end, } map { description = 'Go to Outgoing Call', category = map.CATEGORY.NAVIGATION, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.C .. map.KEY.C, command = function() vim.lsp.buf.outgoing_calls() end, } end if capabilities.rename then map { description = 'Rename symbol', category = map.CATEGORY.EDITING, mode = map.MODE.NORMAL, keys = map.KEY.F2, command = function() vim.lsp.buf.rename() end, } end if capabilities.code_action then map { description = 'Show code actions', category = map.CATEGORY.VIEW, mode = map.MODE.NORMAL, keys = map.KEY.F4, command = function() vim.lsp.buf.code_action() end, } map { description = 'Show code actions in range', category = map.CATEGORY.VIEW, mode = map.MODE.VISUAL, keys = map.KEY.F4, command = function() vim.lsp.buf.range_code_action() end, } end if capabilities.document_highlight then -- this variable should technically be scoped to the current buffer. -- how to do that? local highlight_timer = nil auto 'highlight_reference_under_cursor' { { description = 'Automatically highlight a symbol under cursor', events = 'CursorHold', pattern = '<buffer>', command = function() if not highlight_timer then highlight_timer = vim.defer_fn(function() vim.lsp.buf.document_highlight() highlight_timer = nil end, 866) end end, }, { description = 'Clear highlighted symbol under cursor', events = { 'CursorMoved', 'CursorMovedI', 'InsertEnter' }, pattern = '<buffer>', command = function() if highlight_timer then highlight_timer:close() highlight_timer = nil end vim.lsp.buf.clear_references() end, }, } end end zero.setup()+3 / −3 text lines
+2 / −2 text lines
+6 / −3 text lines
+1 / −1 text lines
+24 / −17 text lines
local group = vim.api.nvim_create_augroup(group_name, { clear = true }) return function(list_of_autocommands) if list_of_autocommands.events then list_of_autocommands = { list_of_autocommands } end for _, autocommand in pairs(list_of_autocommands) do vim.api.nvim_create_autocmd(autocommand.events, { desc = autocommand.description, group = group, pattern = autocommand.pattern, -- command and callback are mutually exclusive. -- one of them has to be nil command = autocommand.command, callback = autocommand.callback, }) end end local group = vim.api.nvim_create_augroup(group_name, { clear = true }) return function(list_of_autocommands) if list_of_autocommands.events then list_of_autocommands = { list_of_autocommands } end for _, autocommand in pairs(list_of_autocommands) do -- command and callback are mutually exclusive. -- one of them has to be nil local command = nil local callback = nil if type(autocommand.command) == 'function' then callback = autocommand.command else command = autocommand.command end vim.api.nvim_create_autocmd(autocommand.events, { desc = autocommand.description, group = group, pattern = autocommand.pattern, command = command, callback = callback, }) end endnew file mode 100644+19 / −0 text lines
local want = require 'bugabinga.std.want'local function get_icon(icon_name) return want { 'nvim-web-devicons' } (function(devicons) return devicons.get_icon(icon_name) end)end --TODO: fill up those iconsreturn setmetatable({ FILE = {}, UI = {}, DOCUMENT = {}, MISC = {},}, { __call = function(_, ...) return get_icon(...) end,})+20 / −3 text lines
+37 / −37 text lines
want { 'toggleterm' }(function(toggleterm) toggleterm.setup { size = 20, open_mapping = [[<LEADER>t]], hide_numbers = true, shade_filetypes = {}, shade_terminals = true, shading_factor = 2, start_in_insert = true, insert_mappings = false, persist_size = true, direction = 'float', close_on_exit = true, shell = vim.o.shell, float_opts = { border = 'curved', winblend = 0, highlights = { border = 'Normal', background = 'Normal', }, }, }want { 'toggleterm' } (function(toggleterm) toggleterm.setup { size = 20, open_mapping = [[<LEADER>t]], hide_numbers = true, shade_filetypes = {}, shade_terminals = true, shading_factor = 2, start_in_insert = true, insert_mappings = false, persist_size = true, direction = 'float', close_on_exit = true, shell = vim.o.shell, float_opts = { border = 'curved', winblend = 0, highlights = { border = 'Normal', background = 'Normal', }, }, } local function set_terminal_keymaps() local opts = { noremap = true } vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts) vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts) vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts) vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts) vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts) end local function set_terminal_keymaps() local opts = { noremap = true } vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts) vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts) vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts) vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts) vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts) end+188 / −142 text lines
local auto = require 'bugabinga.std.auto' configs.setup { -- A list of parser names, or "all" ensure_installed = 'all', -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = true, -- List of parsers to ignore installing (for "all") ignore_install = {}, configs.setup { -- A list of parser names, or "all" -- FIXME: temporarily deactivated, because i am offline -- ensure_installed = 'all', -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = true, -- Automatically install missing parsers when entering buffer auto_install = true, -- List of parsers to ignore installing (for "all") ignore_install = {}, -- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). -- Using this option may slow down your editor, and you may see some duplicate highlights. -- Instead of true it can also be a list of languages additional_vim_regex_highlighting = false, }, incremental_selection = { enable = true, keymaps = { init_selection = 'gnn', node_incremental = 'grn', scope_incremental = 'grc', node_decremental = 'grm', }, }, -- indent on = with TS indent = { enable = true, }, -- These features are mostly useful when there is treesitter parser, but no -- LSP. -- FIXME: harmonize the keybinds with LSP equivalents refactor = 'all', textsubjects = { enable = true, prev_selection = '<Down>', -- (Optional) keymap to select the previous selection keymaps = { ['<Up>'] = 'textsubjects-smart', ['<Right>'] = 'textsubjects-container-outer', ['<Left>'] = 'textsubjects-container-inner', }, }, textobjects = { select = { enable = true, -- Automatically jump forward to textobj, similar to targets.vim lookahead = true, keymaps = { -- You can use the capture groups defined in textobjects.scm ['af'] = '@function.outer', ['if'] = '@function.inner', ['ac'] = '@class.outer', ['ic'] = '@class.inner', }, }, swap = { enable = true, swap_next = { ['<leader>a'] = '@parameter.inner', }, swap_previous = { ['<leader>A'] = '@parameter.inner', }, }, move = { enable = true, set_jumps = true, -- whether to set jumps in the jumplist goto_next_start = { [']m'] = '@function.outer', [']]'] = '@class.outer', }, goto_next_end = { [']M'] = '@function.outer', [']['] = '@class.outer', }, goto_previous_start = { ['[m'] = '@function.outer', ['[['] = '@class.outer', }, goto_previous_end = { ['[M'] = '@function.outer', ['[]'] = '@class.outer', }, }, lsp_interop = { enable = true, border = 'none', peek_definition_code = { ['<leader>df'] = '@function.outer', ['<leader>dc'] = '@class.outer', }, }, }, playground = { enable = true, disable = {}, updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code persist_queries = false, -- Whether the query persists across vim sessions 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 = '?', }, }, context_commentstring = { enable = true, }, -- autoclose and rename tags autotag = { enable = true, }, } -- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). -- Using this option may slow down your editor, and you may see some duplicate highlights. -- Instead of true it can also be a list of languages additional_vim_regex_highlighting = false, }, incremental_selection = { enable = true, keymaps = { init_selection = 'gnn', node_incremental = 'grn', scope_incremental = 'grc', node_decremental = 'grm', }, }, -- indent on = with TS indent = { enable = true, }, -- These features are mostly useful when there is treesitter parser, but no -- LSP. -- FIXME: harmonize the keybinds with LSP equivalents refactor = 'all', textsubjects = { enable = true, prev_selection = '<Down>', -- (Optional) keymap to select the previous selection keymaps = { ['<Up>'] = 'textsubjects-smart', ['<Right>'] = 'textsubjects-container-outer', ['<Left>'] = 'textsubjects-container-inner', }, }, textobjects = { select = { enable = true, -- Automatically jump forward to textobj, similar to targets.vim lookahead = true, keymaps = { -- You can use the capture groups defined in textobjects.scm ['af'] = '@function.outer', ['if'] = '@function.inner', ['ac'] = '@class.outer', ['ic'] = '@class.inner', }, }, swap = { enable = true, swap_next = { ['<leader>a'] = '@parameter.inner', }, swap_previous = { ['<leader>A'] = '@parameter.inner', }, }, move = { enable = true, set_jumps = true, -- whether to set jumps in the jumplist goto_next_start = { [']m'] = '@function.outer', [']]'] = '@class.outer', }, goto_next_end = { [']M'] = '@function.outer', [']['] = '@class.outer', }, goto_previous_start = { ['[m'] = '@function.outer', ['[['] = '@class.outer', }, goto_previous_end = { ['[M'] = '@function.outer', ['[]'] = '@class.outer', }, }, lsp_interop = { enable = true, border = 'rounded', peek_definition_code = { ['<leader>df'] = '@function.outer', ['<leader>dc'] = '@class.outer', }, }, }, playground = { enable = true, disable = {}, updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code persist_queries = false, -- Whether the query persists across vim sessions 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 = '?', }, }, context_commentstring = { enable = true, }, -- autoclose and rename tags autotag = { enable = true, }, } -- generate doc comment annotations -- TODO: setup keybind neogen.setup{ snippet_engine = 'luasnip', } map { description = 'Generate Doc Comment for Function', category = map.CATEGORY.EDITING, mode = map.MODE.NORMAL, keys = map.KEY.LEADER .. map.KEY.N .. map.KEY.F, command = function() neogen.generate{ type = 'func'} end, } -- FIXME: this aucmd needs to be restricted to buffers where treesitter is loaded -- Treesitter highlights tend to highlight syntax errors immediately. -- But that i find distracting while typing. -- Disable the error highlight while typing, but keep it in normal mode. auto 'disable_error_highlight_while_typing' { { description = 'Disable the @error highlight while in Insert mode', events = 'InsertEnter', pattern = '*', command = function() want { 'nvim-treesitter.highlight' } (function(highlight) pcall(highlight.stop) pcall(highlight.set_custom_captures, { error = 'None' }) pcall(highlight.start) end) end, }, { description = 'Enable the @error highlight while in Normal mode', events = 'InsertLeave', pattern = '*', command = function() want { 'nvim-treesitter.highlight' } (function(highlight) pcall(highlight.stop) pcall(highlight.set_custom_captures, { error = 'TSError' }) pcall(highlight.start) end) end, }, }+2 / −1 text lines