repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim: treesitter conceal for lua

a21a2de0f51168b36fa17f870bdd45ccb7746ed4

Oliver Jan Krylow <olver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (20)

+1000 / −487 text lines

Diff layout

neovim/after/queries/lua/highlights.scm

Added
new file mode 100644

+12 / −0 text lines

1(("local" @keyword) (#set! conceal "⋅"))
2(("function" @keyword.function) (#set! conceal "ϝ"))
3(("end" @keyword.function) (#set! conceal "∎"))
4(("return" @keyword.return) (#set! conceal "↳"))
5(("then" @conditional) (#set! conceal "⟶"))
6
7((dot_index_expression table: (identifier) @variable (#eq? @variable "vim")) (#set! conceal ""))
8
9((function_call name: (identifier) @function (#eq? @function "require")) (#set! conceal ""))
11; ((function_call name: (identifier) @function (#eq? @function "want")) (#set! conceal "ω"))
12; ((local_declaration name: (identifier) @variable (#eq? @variable "want") (#set! conceal "ω"))

neovim/ftplugin/lua.lua

Modified

+4 / −0 text lines

1-- conceal some syntax with pretty symbols and show them only in
2-- insert mode. see after/queries/lua/highlights.scm for more.
3vim.opt_local.conceallevel = 2
4vim.opt_local.concealcursor = 'nc'

neovim/init.lua

Modified

+12 / −13 text lines

2929-- load ui stuff
3030require 'bugabinga.notify'
3131require 'bugabinga.colortheme'
32require 'bugabinga.icons'
32require 'bugabinga.devicons'
3333require 'bugabinga.colorcolumn'
3434require 'bugabinga.fuzzy-search-ui'
3535require 'bugabinga.colorizer'
6262-- lsp
6363require 'bugabinga.lsp'
65-- TODO: DAP
66-- TODO: put all keybinds into facade
67-- TODO: preview multimedia with telescope
68-- TODO: icon facade: icon.get("name")
69-- TODO: use nvim-specific lsp only in neovim config
70-- TODO: is it possible to cache LSP init per project?
71-- TODO: stop treesitter error highlight while typing
65-- diagnostic
66require 'bugabinga.diagnostic'
7268-- TODO: fix gitsigns highights
69-- TODO: preview multimedia with telescope
70-- TODO: nugu theme
7371-- TODO: hydra cycle buffers
74-- TODO: add fstabfmt to null-ls
75-- TODO: load plugins/init.lua and sync on write. reload init.lua?
76-- TODO: lsp diagnostics hide in insert mode
7772-- TODO: cross platform status bar
7873-- TODO: show winbar
7974-- TODO: show read only files in winbar
80-- TODO: make cursor red if diagnostics
81-- TODO: toggle diagnostics keybind
75-- TODO: load plugins/init.lua and sync on write. reload init.lua?
76-- TODO: use nvim-specific lsp only in neovim config
77-- TODO: steal filetype settings from shark, astrovim, lunarvim etc
78-- TODO: is it possible to cache LSP init per project?
79-- TODO: DAP
80-- TODO: fix cursor flicker when openinig neotree and other windows stuff in lsp buffers
8382--
8483-- PLUGINS TO TRY

neovim/lua/bugabinga/colortheme.lua

Modified

+8 / −0 text lines

11local want = require 'bugabinga.std.want'
22want { 'boo-colorscheme' } (function(boo)
33 boo.use()
4 vim.api.nvim_set_hl(0, 'LspReferenceText', {})
5 vim.api.nvim_set_hl(0, 'LspReferenceRead', {
6 standout = true,
7 })
8 vim.api.nvim_set_hl(0, 'LspReferenceWrite', {
9 standout = true,
10 bold = true,
11 })
412end)

neovim/lua/bugabinga/devicons.lua

Added
new file mode 100644

+125 / −0 text lines

1-- TODO: once the colortheme is lushified, use it as a source of colors here
2local want = require 'bugabinga.std.want'
3want { 'nvim-web-devicons' } (function(devicons)
4 devicons.setup {
5 -- return a default icon when icon query cannot be mapped to existing icon
6 default = true,
7 override = {
8 --
9 -- FILE
10 sh = { icon = '', color = '#1DC123', cterm_color = '59', name = 'Sh' },
11 toml = { icon = '', color = '#e24329', cterm_color = '59', name = 'Toml' },
12 justfile = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' },
13 Justfile = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' },
14 ['.justfile'] = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' },
15 ['.Justfile'] = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' },
16 ['.gitattributes'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitAttributes' },
17 ['.gitconfig'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitConfig' },
18 ['.gitignore'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitIgnore' },
19 ['.gitlab-ci.yml'] = { icon = '', color = '#e24329', cterm_color = '166', name = 'GitlabCI' },
20 ['.gitmodules'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitModules' },
21 ['diff'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'Diff' },
22 --
23 -- KIND
24 Text = { icon = '', color = '#949494', cterm_color = '59', name = 'TextSymbol' },
25 Method = { icon = 'm', color = '#949494', cterm_color = '59', name = 'MethodSymbol' },
26 Function = { icon = '', color = '#949494', cterm_color = '59', name = 'FunctionSymbol' },
27 Constructor = { icon = '', color = '#949494', cterm_color = '59', name = 'ConstructorSymbol' },
28 Field = { icon = '', color = '#949494', cterm_color = '59', name = 'FieldSymbol' },
29 Variable = { icon = '', color = '#949494', cterm_color = '59', name = 'VariableSymbol' },
30 Class = { icon = '', color = '#949494', cterm_color = '59', name = 'ClassSymbol' },
31 Interface = { icon = '', color = '#949494', cterm_color = '59', name = 'InterfaceSymbol' },
32 Module = { icon = '', color = '#949494', cterm_color = '59', name = 'ModuleSymbol' },
33 Property = { icon = '', color = '#949494', cterm_color = '59', name = 'PropertySymbol' },
34 Unit = { icon = '', color = '#949494', cterm_color = '59', name = 'UnitSymbol' },
35 Value = { icon = '', color = '#949494', cterm_color = '59', name = 'ValueSymbol' },
36 Enum = { icon = '', color = '#949494', cterm_color = '59', name = 'EnumSymbol' },
37 Keyword = { icon = '', color = '#949494', cterm_color = '59', name = 'KeywordSymbol' },
38 Snippet = { icon = '', color = '#949494', cterm_color = '59', name = 'SnippetSymbol' },
39 Color = { icon = '', color = '#949494', cterm_color = '59', name = 'ColorSymbol' },
40 File = { icon = '', color = '#949494', cterm_color = '59', name = 'FileSymbol' },
41 Reference = { icon = '', color = '#949494', cterm_color = '59', name = 'ReferenceSymbol' },
42 Folder = { icon = '', color = '#949494', cterm_color = '59', name = 'FolderSymbol' },
43 EnumMember = { icon = '', color = '#949494', cterm_color = '59', name = 'EnumMemberSymbol' },
44 Constant = { icon = '', color = '#949494', cterm_color = '59', name = 'ConstantSymbol' },
45 Struct = { icon = '', color = '#949494', cterm_color = '59', name = 'StructSymbol' },
46 Event = { icon = '', color = '#949494', cterm_color = '59', name = 'EventSymbol' },
47 Operator = { icon = '', color = '#949494', cterm_color = '59', name = 'OperatorSymbol' },
48 TypeParameter = { icon = '', color = '#949494', cterm_color = '59', name = 'TypeParameterSymbol' },
49 --
50 -- TYPE
51 Array = { icon = '', color = '#949494', cterm_color = '59', name = 'ArraySymbol' },
52 Number = { icon = '', color = '#949494', cterm_color = '59', name = 'NumberSymbol' },
53 String = { icon = '', color = '#949494', cterm_color = '59', name = 'StringSymbol' },
54 Boolean = { icon = '蘒', color = '#949494', cterm_color = '59', name = 'BooleanSymbol' },
55 Object = { icon = '', color = '#949494', cterm_color = '59', name = 'ObjectSymbol' },
56 --
57 -- DOCUMENTS
58 Files = { icon = '', color = '#949494', cterm_color = '59', name = 'FilesSymbol' },
59 OpenFolder = { icon = '', color = '#949494', cterm_color = '59', name = 'OpenFolderSymbol' },
60 EmptyFolder = { icon = '', color = '#949494', cterm_color = '59', name = 'EmptyFolderSymbol' },
61 --
62 -- VCS
63 VcsAdded = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsAddedSymbol' },
64 VcsModified = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsModifiedSymbol' },
65 VcsRemoved = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRemovedSymbol' },
66 VcsIgnored = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsIgnoredSymbol' },
67 VcsRenamed = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRenamedSymbol' },
68 VcsDiff = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsDiffSymbol' },
69 VcsRepo = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRepoSymbol' },
70 VcsUntracked = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsUntrackedSymbol' },
71 VcsUnstaged = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsUnstagedSymbol' },
72 VcsStaged = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsStagedSymbol' },
73 VcsConflicted = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsConflictedSymbol' },
74 --
75 --UI
76 ArrowClosed = { icon = '', color = '#949494', cterm_color = '59', name = 'ArrowClosedSymbol' },
77 ArrowOpen = { icon = '', color = '#949494', cterm_color = '59', name = 'ArrowOpenSymbol' },
78 Lock = { icon = '', color = '#949494', cterm_color = '59', name = 'LockSymbol' },
79 Circle = { icon = '', color = '#949494', cterm_color = '59', name = 'CircleSymbol' },
80 BigCircle = { icon = '', color = '#949494', cterm_color = '59', name = 'BigCircleSymbol' },
81 BigUnfilledCircle = { icon = '', color = '#949494', cterm_color = '59', name = 'BigUnfilledCircleSymbol' },
82 Close = { icon = '', color = '#949494', cterm_color = '59', name = 'CloseSymbol' },
83 NewFile = { icon = '', color = '#949494', cterm_color = '59', name = 'NewFileSymbol' },
84 Search = { icon = '', color = '#949494', cterm_color = '59', name = 'SearchSymbol' },
85 Lightbulb = { icon = '', color = '#949494', cterm_color = '59', name = 'LightbulbSymbol' },
86 Project = { icon = '', color = '#949494', cterm_color = '59', name = 'ProjectSymbol' },
87 Dashboard = { icon = '', color = '#949494', cterm_color = '59', name = 'DashboardSymbol' },
88 History = { icon = '', color = '#949494', cterm_color = '59', name = 'HistorySymbol' },
89 Comment = { icon = '', color = '#949494', cterm_color = '59', name = 'CommentSymbol' },
90 Bug = { icon = '', color = '#949494', cterm_color = '59', name = 'BugSymbol' },
91 Code = { icon = '', color = '#949494', cterm_color = '59', name = 'CodeSymbol' },
92 Telescope = { icon = '', color = '#949494', cterm_color = '59', name = 'TelescopeSymbol' },
93 Gear = { icon = '', color = '#949494', cterm_color = '59', name = 'GearSymbol' },
94 Package = { icon = '', color = '#949494', cterm_color = '59', name = 'PackageSymbol' },
95 List = { icon = '', color = '#949494', cterm_color = '59', name = 'ListSymbol' },
96 SignIn = { icon = '', color = '#949494', cterm_color = '59', name = 'SignInSymbol' },
97 SignOut = { icon = '', color = '#949494', cterm_color = '59', name = 'SignOutSymbol' },
98 Check = { icon = '', color = '#949494', cterm_color = '59', name = 'CheckSymbol' },
99 Fire = { icon = '', color = '#949494', cterm_color = '59', name = 'FireSymbol' },
100 Note = { icon = '', color = '#949494', cterm_color = '59', name = 'NoteSymbol' },
101 BookMark = { icon = '', color = '#949494', cterm_color = '59', name = 'BookMarkSymbol' },
102 Pencil = { icon = '', color = '#949494', cterm_color = '59', name = 'PencilSymbol' },
103 ChevronRight = { icon = '', color = '#949494', cterm_color = '59', name = 'ChevronRightSymbol' },
104 Table = { icon = '', color = '#949494', cterm_color = '59', name = 'TableSymbol' },
105 Calendar = { icon = '', color = '#949494', cterm_color = '59', name = 'CalendarSymbol' },
106 CloudDownload = { icon = '', color = '#949494', cterm_color = '59', name = 'CloudDownloadSymbol' },
107 --
108 -- DIAGNOSTICS
109 Error = { icon = '', color = '#949494', cterm_color = '59', name = 'ErrorSymbol' },
110 Warning = { icon = '', color = '#949494', cterm_color = '59', name = 'WarningSymbol' },
111 Information = { icon = '', color = '#949494', cterm_color = '59', name = 'InformationSymbol' },
112 Question = { icon = '', color = '#949494', cterm_color = '59', name = 'QuestionSymbol' },
113 Hint = { icon = '', color = '#949494', cterm_color = '59', name = 'HintSymbol' },
114 --
115 -- MISCELLANEOUS
116 Robot = { icon = 'ﮧ', color = '#949494', cterm_color = '59', name = 'RobotSymbol' },
117 Squirrel = { icon = '', color = '#949494', cterm_color = '59', name = 'SquirrelSymbol' },
118 Tag = { icon = '', color = '#949494', cterm_color = '59', name = 'TagSymbol' },
119 Watch = { icon = '', color = '#949494', cterm_color = '59', name = 'WatchSymbol' },
120 },
121 }
122 -- devicons will return some default icon, when an icon name could not be mapped.
123 -- in order to quickly notice these cases and debug them, set a noticeable icon as default.
124 devicons.set_default_icon('ﴫ', '#ff00ff')
125end)

neovim/lua/bugabinga/diagnostic.lua

Added
new file mode 100644

+153 / −0 text lines

1-- the topic 'diagnotics' was refactored out of LSP into its own thing some time
2-- ago. that is why it gets its own section in this config now, but right now,
3-- those settings overlap with lsp-zero.
4
5local auto = require 'bugabinga.std.auto'
6local map = require 'bugabinga.std.keymap'
7local icon = require 'bugabinga.std.icon'
8
9local diagnostic = vim.diagnostic
11local diagnostic_format = function(context)
12 local message = context.message
13 local severity = context.severity
14 local symbol = ''
15 if severity == diagnostic.severity.ERROR then
16 symbol = icon 'Error'
17 elseif severity == diagnostic.severity.WARN then
18 symbol = icon 'Warning'
19 elseif severity == diagnostic.severity.INFO then
20 symbol = icon 'Information'
21 elseif severity == diagnostic.severity.HINT then
22 symbol = icon 'Hint'
23 end
24 return string.format('%s | %s', symbol, message)
25end
27local prefix_format = function(context, index, total)
28 local source = context.source
29 local severity = context.severity
30 local symbol = ''
31 if severity == diagnostic.severity.ERROR then
32 symbol = icon 'Error'
33 elseif severity == diagnostic.severity.WARN then
34 symbol = icon 'Warning'
35 elseif severity == diagnostic.severity.INFO then
36 symbol = icon 'Information'
37 elseif severity == diagnostic.severity.HINT then
38 symbol = icon 'Hint'
39 end
40 return string.format('%s/%s %s %s ', index, total, source, symbol)
41end
43diagnostic.config {
44 underline = {
45 severity = diagnostic.severity.ERROR,
46 },
47 virtual_text = {
48 severity = diagnostic.severity.HINT,
49 source = false,
50 spacing = 0,
51 prefix = '',
52 format = diagnostic_format,
53 },
54 float = {
55 focusable = false,
56 style = 'minimal',
57 border = 'rounded',
58 source = false,
59 header = '',
60 prefix = prefix_format,
61 },
62 update_in_insert = false,
63 signs = true,
64 severity_sort = true,
65}
67local sign = function(options)
68 vim.fn.sign_define(options.name, {
69 texthl = options.name,
70 text = options.text,
71 numhl = '',
72 })
73end
75sign { name = 'DiagnosticSignError', text = icon 'Error' }
76sign { name = 'DiagnosticSignWarn', text = icon 'Warning' }
77sign { name = 'DiagnosticSignHint', text = icon 'Hint' }
78sign { name = 'DiagnosticSignInfo', text = icon 'Information' }
80auto 'hide_diagnostics' {
81 description = 'Hide diagnostics by default',
82 events = { 'BufReadPre' },
83 pattern = '*',
84 command = function()
85 diagnostic.disable(0)
86 end,
87}
88local saved_cursor_highlight = vim.api.nvim_get_hl_by_name('Cursor', true)
89-- TODO: get colors from theme
90local noticeable = { foreground = '#ffffff', background = '#ff0000'}
92auto 'cursor_attention_if_diagnostics' {
93 description = 'Make cursor very noticeable, if diagnostics are present',
94 events = 'DiagnosticChanged',
95 pattern = '*',
96 command = function()
97 local diagnostic_number = #vim.diagnostic.get(0,{severity = vim.diagnostic.severity.ERROR})
98 if diagnostic_number > 0 then
99 vim.api.nvim_set_hl(0, 'Cursor', noticeable)
100 else
101 vim.api.nvim_set_hl(0, 'Cursor', saved_cursor_highlight)
102 end
103 end,
104}
106map {
107 description = 'Enable diagnostics',
108 category = map.CATEGORY.PROBLEMS,
109 mode = map.MODE.NORMAL,
110 keys = map.KEY.LEADER .. map.KEY.P,
111 command = function()
112 diagnostic.enable(0)
113 end,
114}
115map {
116 description = 'Disable diagnostics',
117 category = map.CATEGORY.PROBLEMS,
118 mode = map.MODE.NORMAL,
119 keys = map.KEY.LEADER .. map.KEY.P .. map.KEY.P,
120 command = function()
121 diagnostic.disable(0)
122 end,
123}
124map {
125 description = 'Show diagnostics in float window',
126 category = map.CATEGORY.PROBLEMS,
127 mode = map.MODE.NORMAL,
128 keys = map.KEY.F6,
129 command = function()
130 diagnostic.enable(0)
131 diagnostic.open_float()
132 end,
133}
134map {
135 description = 'Go to previous diagnostic',
136 category = map.CATEGORY.PROBLEMS,
137 mode = map.MODE.NORMAL,
138 keys = map.KEY.F7,
139 command = function()
140 diagnostic.enable(0)
141 diagnostic.goto_prev()
142 end,
143}
144map {
145 description = 'Go to next diagnostic',
146 category = map.CATEGORY.PROBLEMS,
147 mode = map.MODE.NORMAL,
148 keys = map.KEY.F8,
149 command = function()
150 diagnostic.enable(0)
151 diagnostic.goto_next()
152 end,
153}

neovim/lua/bugabinga/file-explorer.lua

Modified

+29 / −31 text lines

11local want = require 'bugabinga.std.want'
2local map = require'bugabinga.std.keymap'
3local fmt = require'bugabinga.std.fmt'
2local map = require 'bugabinga.std.keymap'
3local fmt = require 'bugabinga.std.fmt'
4local icon = require 'bugabinga.std.icon'
56want {
67 'window-picker',
78 'neo-tree',
8 'nvim-web-devicons',
9} (function(picker, tree, icons)
10 local icon = icons.get_icon
9} (function(picker, tree)
1210 picker.setup {
1311 autoselect_one = true,
1412 include_current = false,
2927 -- Unless you are still migrating, remove the deprecated commands from v1.x
3028 vim.g.neo_tree_remove_legacy_commands = 1
32 map{
33 description = "Open File Explorer",
30 map {
31 description = 'Open File Explorer',
3432 category = map.CATEGORY.NAVIGATION,
3533 mode = map.MODE.NORMAL,
3634 keys = map.KEY.LEADER .. map.KEY.E,
37 command = fmt.cmd'Neotree filesystem reveal right toggle',
35 command = fmt.cmd 'Neotree filesystem reveal right toggle',
3836 }
39 map{
40 description = "Open Buffer Explorer",
37 map {
38 description = 'Open Buffer Explorer',
4139 category = map.CATEGORY.NAVIGATION,
4240 mode = map.MODE.NORMAL,
4341 keys = map.KEY.LEADER .. map.KEY.E .. map.KEY.B,
44 command = fmt.cmd'Neotree buffers reveal float toggle',
42 command = fmt.cmd 'Neotree buffers reveal float toggle',
4543 }
46 map{
47 description = "Open Git Explorer",
44 map {
45 description = 'Open Git Explorer',
4846 category = map.CATEGORY.NAVIGATION,
4947 mode = map.MODE.NORMAL,
5048 keys = map.KEY.LEADER .. map.KEY.E .. map.KEY.G,
51 command = fmt.cmd'Neotree git_status reveal current toggle',
49 command = fmt.cmd 'Neotree git_status reveal current toggle',
5250 }
5452 tree.setup {
9391 highlight = 'NeoTreeIndentMarker',
9492 -- expander config, needed for nesting files
9593 with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
96 expander_collapsed = icon'ArrowClosed',
97 expander_expanded = icon'ArrowOpen',
94 expander_collapsed = icon 'ArrowClosed',
95 expander_expanded = icon 'ArrowOpen',
9896 expander_highlight = 'NeoTreeExpander',
9997 },
10098 icon = {
101 folder_closed = icon'Folder',
102 folder_open = icon'OpenFolder',
103 folder_empty = icon'EmptyFolder',
99 folder_closed = icon 'Folder',
100 folder_open = icon 'OpenFolder',
101 folder_empty = icon 'EmptyFolder',
104102 },
105103 modified = {
106 symbol = icon'VcsModified',
104 symbol = icon 'VcsModified',
107105 highlight = 'NeoTreeModified',
108106 },
109107 name = {
114112 git_status = {
115113 symbols = {
116114 -- Change type
117 added = icon'VcsAdded',
118 deleted =icon'VcsRemoved',
119 modified = icon'VcsModified',
120 renamed = icon'VcsRenamed',
115 added = icon 'VcsAdded',
116 deleted = icon 'VcsRemoved',
117 modified = icon 'VcsModified',
118 renamed = icon 'VcsRenamed',
121119 -- Status type
122 untracked = icon'VcsUntracked',
123 ignored = icon'VcsIgnored',
124 unstaged = icon'VcsUnstaged',
125 staged = icon'VcsStaged',
126 conflict = icon'VcsConflicted',
120 untracked = icon 'VcsUntracked',
121 ignored = icon 'VcsIgnored',
122 unstaged = icon 'VcsUnstaged',
123 staged = icon 'VcsStaged',
124 conflict = icon 'VcsConflicted',
127125 },
128126 align = 'right',
129127 },
221219 },
222220 ['A'] = 'add_directory', -- also accepts the config.show_path option.
223221 ['d'] = 'delete',
224 ['r'] = 'rename',
222 ['<F2>'] = 'rename',
225223 ['y'] = 'copy_to_clipboard',
226224 ['x'] = 'cut_to_clipboard',
227225 ['p'] = 'paste_from_clipboard',

neovim/lua/bugabinga/git-status.lua

Modified

+69 / −4 text lines

1local fmt = require 'bugabinga.std.fmt'
2local map = require 'bugabinga.std.keymap'
13local want = require 'bugabinga.std.want'
2want { 'gitsigns' }(function(gitsigns)
3 -- FIXME use keymap facade
4 -- FIXME integrate into null-ls
5 gitsigns.setup()
4
5want { 'gitsigns' } (function(gitsigns)
6 map {
7 description = 'toogle git status line highlight',
8 category = map.CATEGORY.VERSION_CONTROL,
9 mode = map.MODE.NORMAL,
10 keys = map.KEY.LEADER .. map.KEY.V .. map.KEY.L,
11 command = fmt.cmd'gitsigns toggle_linehl',
12 }
13 map {
14 description = 'toogle git status signs',
15 category = map.CATEGORY.VERSION_CONTROL,
16 mode = map.MODE.NORMAL,
17 keys = map.KEY.LEADER .. map.KEY.V .. map.KEY.S,
18 command = fmt.cmd'gitsigns toggle_signs',
19 }
20 map {
21 description = 'Toogle Git Blame Line',
22 category = map.CATEGORY.VERSION_CONTROL,
23 mode = map.MODE.NORMAL,
24 keys = map.KEY.LEADER .. map.KEY.V .. map.KEY.B,
25 command = fmt.cmd'Gitsigns toggle_current_line_blame',
26 }
27 gitsigns.setup {
28 signs = {
29 add = { hl = 'GitSignsAdd', text = '│', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn' },
30 change = { hl = 'GitSignsChange', text = '│', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
31 delete = { hl = 'GitSignsDelete', text = '_', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
32 topdelete = { hl = 'GitSignsDelete', text = '‾', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
33 changedelete = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
34 },
35 signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
36 numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
37 linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
38 word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
39 diff_opts = {
40 internal = true,
41 },
42 watch_gitdir = {
43 interval = 1000,
44 follow_files = true,
45 },
46 attach_to_untracked = true,
47 current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
48 current_line_blame_opts = {
49 virt_text = true,
50 virt_text_pos = 'right_align', -- 'eol' | 'overlay' | 'right_align'
51 delay = 866,
52 ignore_whitespace = true,
53 },
54 current_line_blame_formatter = '<author>, <author_time:%d/%m/%Y> - <summary>',
55 sign_priority = 6,
56 update_debounce = 100,
57 status_formatter = nil, -- Use default
58 max_file_length = 40000,
59 preview_config = {
60 -- Options passed to nvim_open_win
61 border = 'rounded',
62 style = 'minimal',
63 relative = 'cursor',
64 row = 0,
65 col = 1,
66 },
67 yadm = {
68 enable = false,
69 },
70 }
671end)

neovim/lua/bugabinga/icons.lua

Deleted
deleted file mode 100644

+0 / −125 text lines

1-- TODO: once the colortheme is lushified, use it as a source of colors here
2local want = require 'bugabinga.std.want'
3want { 'nvim-web-devicons' } (function(devicons)
4 devicons.setup {
5 -- return a default icon when icon query cannot be mapped to existing icon
6 default = true,
7 override = {
8 --
9 -- FILE
10 sh = { icon = '', color = '#1DC123', cterm_color = '59', name = 'Sh' },
11 toml = { icon = '', color = '#e24329', cterm_color = '59', name = 'Toml' },
12 justfile = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' },
13 Justfile = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' },
14 ['.justfile'] = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' },
15 ['.Justfile'] = { icon = 'ﮧ', color = '#999eff', cterm_color = '59', name = 'Justfile' },
16 ['.gitattributes'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitAttributes' },
17 ['.gitconfig'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitConfig' },
18 ['.gitignore'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitIgnore' },
19 ['.gitlab-ci.yml'] = { icon = '', color = '#e24329', cterm_color = '166', name = 'GitlabCI' },
20 ['.gitmodules'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'GitModules' },
21 ['diff'] = { icon = '', color = '#e24329', cterm_color = '59', name = 'Diff' },
22 --
23 -- KIND
24 Text = { icon = '', color = '#949494', cterm_color = '59', name = 'TextSymbol' },
25 Method = { icon = 'm', color = '#949494', cterm_color = '59', name = 'MethodSymbol' },
26 Function = { icon = '', color = '#949494', cterm_color = '59', name = 'FunctionSymbol' },
27 Constructor = { icon = '', color = '#949494', cterm_color = '59', name = 'ConstructorSymbol' },
28 Field = { icon = '', color = '#949494', cterm_color = '59', name = 'FieldSymbol' },
29 Variable = { icon = '', color = '#949494', cterm_color = '59', name = 'VariableSymbol' },
30 Class = { icon = '', color = '#949494', cterm_color = '59', name = 'ClassSymbol' },
31 Interface = { icon = '', color = '#949494', cterm_color = '59', name = 'InterfaceSymbol' },
32 Module = { icon = '', color = '#949494', cterm_color = '59', name = 'ModuleSymbol' },
33 Property = { icon = '', color = '#949494', cterm_color = '59', name = 'PropertySymbol' },
34 Unit = { icon = '', color = '#949494', cterm_color = '59', name = 'UnitSymbol' },
35 Value = { icon = '', color = '#949494', cterm_color = '59', name = 'ValueSymbol' },
36 Enum = { icon = '', color = '#949494', cterm_color = '59', name = 'EnumSymbol' },
37 Keyword = { icon = '', color = '#949494', cterm_color = '59', name = 'KeywordSymbol' },
38 Snippet = { icon = '', color = '#949494', cterm_color = '59', name = 'SnippetSymbol' },
39 Color = { icon = '', color = '#949494', cterm_color = '59', name = 'ColorSymbol' },
40 File = { icon = '', color = '#949494', cterm_color = '59', name = 'FileSymbol' },
41 Reference = { icon = '', color = '#949494', cterm_color = '59', name = 'ReferenceSymbol' },
42 Folder = { icon = '', color = '#949494', cterm_color = '59', name = 'FolderSymbol' },
43 EnumMember = { icon = '', color = '#949494', cterm_color = '59', name = 'EnumMemberSymbol' },
44 Constant = { icon = '', color = '#949494', cterm_color = '59', name = 'ConstantSymbol' },
45 Struct = { icon = '', color = '#949494', cterm_color = '59', name = 'StructSymbol' },
46 Event = { icon = '', color = '#949494', cterm_color = '59', name = 'EventSymbol' },
47 Operator = { icon = '', color = '#949494', cterm_color = '59', name = 'OperatorSymbol' },
48 TypeParameter = { icon = '', color = '#949494', cterm_color = '59', name = 'TypeParameterSymbol' },
49 --
50 -- TYPE
51 Array = { icon = '', color = '#949494', cterm_color = '59', name = 'ArraySymbol' },
52 Number = { icon = '', color = '#949494', cterm_color = '59', name = 'NumberSymbol' },
53 String = { icon = '', color = '#949494', cterm_color = '59', name = 'StringSymbol' },
54 Boolean = { icon = '蘒', color = '#949494', cterm_color = '59', name = 'BooleanSymbol' },
55 Object = { icon = '', color = '#949494', cterm_color = '59', name = 'ObjectSymbol' },
56 --
57 -- DOCUMENTS
58 Files = { icon = '', color = '#949494', cterm_color = '59', name = 'FilesSymbol' },
59 OpenFolder = { icon = '', color = '#949494', cterm_color = '59', name = 'OpenFolderSymbol' },
60 EmptyFolder = { icon = '', color = '#949494', cterm_color = '59', name = 'EmptyFolderSymbol' },
61 --
62 -- VCS
63 VcsAdded = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsAddedSymbol' },
64 VcsModified = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsModifiedSymbol' },
65 VcsRemoved = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRemovedSymbol' },
66 VcsIgnored = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsIgnoredSymbol' },
67 VcsRenamed = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRenamedSymbol' },
68 VcsDiff = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsDiffSymbol' },
69 VcsRepo = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsRepoSymbol' },
70 VcsUntracked = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsUntrackedSymbol' },
71 VcsUnstaged = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsUnstagedSymbol' },
72 VcsStaged = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsStagedSymbol' },
73 VcsConflicted = { icon = '', color = '#949494', cterm_color = '59', name = 'VcsConflictedSymbol' },
74 --
75 --UI
76 ArrowClosed = { icon = '', color = '#949494', cterm_color = '59', name = 'ArrowClosedSymbol' },
77 ArrowOpen = { icon = '', color = '#949494', cterm_color = '59', name = 'ArrowOpenSymbol' },
78 Lock = { icon = '', color = '#949494', cterm_color = '59', name = 'LockSymbol' },
79 Circle = { icon = '', color = '#949494', cterm_color = '59', name = 'CircleSymbol' },
80 BigCircle = { icon = '', color = '#949494', cterm_color = '59', name = 'BigCircleSymbol' },
81 BigUnfilledCircle = { icon = '', color = '#949494', cterm_color = '59', name = 'BigUnfilledCircleSymbol' },
82 Close = { icon = '', color = '#949494', cterm_color = '59', name = 'CloseSymbol' },
83 NewFile = { icon = '', color = '#949494', cterm_color = '59', name = 'NewFileSymbol' },
84 Search = { icon = '', color = '#949494', cterm_color = '59', name = 'SearchSymbol' },
85 Lightbulb = { icon = '', color = '#949494', cterm_color = '59', name = 'LightbulbSymbol' },
86 Project = { icon = '', color = '#949494', cterm_color = '59', name = 'ProjectSymbol' },
87 Dashboard = { icon = '', color = '#949494', cterm_color = '59', name = 'DashboardSymbol' },
88 History = { icon = '', color = '#949494', cterm_color = '59', name = 'HistorySymbol' },
89 Comment = { icon = '', color = '#949494', cterm_color = '59', name = 'CommentSymbol' },
90 Bug = { icon = '', color = '#949494', cterm_color = '59', name = 'BugSymbol' },
91 Code = { icon = '', color = '#949494', cterm_color = '59', name = 'CodeSymbol' },
92 Telescope = { icon = '', color = '#949494', cterm_color = '59', name = 'TelescopeSymbol' },
93 Gear = { icon = '', color = '#949494', cterm_color = '59', name = 'GearSymbol' },
94 Package = { icon = '', color = '#949494', cterm_color = '59', name = 'PackageSymbol' },
95 List = { icon = '', color = '#949494', cterm_color = '59', name = 'ListSymbol' },
96 SignIn = { icon = '', color = '#949494', cterm_color = '59', name = 'SignInSymbol' },
97 SignOut = { icon = '', color = '#949494', cterm_color = '59', name = 'SignOutSymbol' },
98 Check = { icon = '', color = '#949494', cterm_color = '59', name = 'CheckSymbol' },
99 Fire = { icon = '', color = '#949494', cterm_color = '59', name = 'FireSymbol' },
100 Note = { icon = '', color = '#949494', cterm_color = '59', name = 'NoteSymbol' },
101 BookMark = { icon = '', color = '#949494', cterm_color = '59', name = 'BookMarkSymbol' },
102 Pencil = { icon = '', color = '#949494', cterm_color = '59', name = 'PencilSymbol' },
103 ChevronRight = { icon = '', color = '#949494', cterm_color = '59', name = 'ChevronRightSymbol' },
104 Table = { icon = '', color = '#949494', cterm_color = '59', name = 'TableSymbol' },
105 Calendar = { icon = '', color = '#949494', cterm_color = '59', name = 'CalendarSymbol' },
106 CloudDownload = { icon = '', color = '#949494', cterm_color = '59', name = 'CloudDownloadSymbol' },
107 --
108 -- DIAGNOSTICS
109 Error = { icon = '', color = '#949494', cterm_color = '59', name = 'ErrorSymbol' },
110 Warning = { icon = '', color = '#949494', cterm_color = '59', name = 'WarningSymbol' },
111 Information = { icon = '', color = '#949494', cterm_color = '59', name = 'InformationSymbol' },
112 Question = { icon = '', color = '#949494', cterm_color = '59', name = 'QuestionSymbol' },
113 Hint = { icon = '', color = '#949494', cterm_color = '59', name = 'HintSymbol' },
114 --
115 -- MISCELLANEOUS
116 Robot = { icon = 'ﮧ', color = '#949494', cterm_color = '59', name = 'RobotSymbol' },
117 Squirrel = { icon = '', color = '#949494', cterm_color = '59', name = 'SquirrelSymbol' },
118 Tag = { icon = '', color = '#949494', cterm_color = '59', name = 'TagSymbol' },
119 Watch = { icon = '', color = '#949494', cterm_color = '59', name = 'WatchSymbol' },
120 },
121 }
122 -- devicons will return some default icon, when an icon name could not be mapped.
123 -- in order to quickly notice these cases and debug them, set a noticeable icon as default.
124 devicons.set_default_icon('ﴫ', '#ff00ff')
125end)

neovim/lua/bugabinga/lsp.lua

Modified

+286 / −105 text lines

1local icon = require 'bugabinga.std.icon'
2local map = require 'bugabinga.std.keymap'
3local auto = require 'bugabinga.std.auto'
4local project = require 'bugabinga.std.project'
15local want = require 'bugabinga.std.want'
6
7-- TODO: setup codelens -> use lsp-signature plugin?
8-- TODO: setup custom cmp keybinds
29want {
3 'lsp-zero',
4 'null-ls',
5 'nvim-lsp-installer',
6 'lua-dev',
7 'rust-tools',
8 'nvim-navic',
9 'lsp-status',
10}(function(zero, null_ls, installer, luadev, rust, navic, lsp_status)
11 installer.settings {
12 ui = {
13 border = 'rounded',
14 },
15 }
10 'lsp-zero',
11 'null-ls',
12 'nvim-lsp-installer',
13 'lua-dev',
14 'rust-tools',
15 'nvim-navic',
16 'lsp-status',
17} (function(zero, null_ls, installer, luadev, rust, navic, lsp_status)
18 installer.settings {
19 ui = {
20 --TODO: use some global float window settings
21 border = 'rounded',
22 },
23 }
17 zero.preset 'recommended'
25 zero.preset 'recommended'
26 zero.set_preferences {
27 configure_diagnostics = false,
28 set_lsp_keymaps = false,
29 sign_icons = {
30 error = icon 'Error',
31 warn = icon 'Warning',
32 hint = icon 'Hint',
33 info = icon 'Information',
34 },
35 }
19 -- setup lsp for my neovim config
20 zero.nvim_workspace {
21 -- add paths of all plugins and neovim
22 library = vim.api.nvim_get_runtime_file('', true),
23 }
24 -- Initialize rust_analyzer with rust-tools
25 rust.setup {
26 server = zero.build_options('rust_analyzer', {}),
27 }
37 -- setup lsp for my neovim config
38 zero.nvim_workspace {
39 -- add paths of all plugins and neovim
40 library = vim.api.nvim_get_runtime_file('', true),
41 }
42 -- Initialize rust_analyzer with rust-tools
43 rust.setup {
44 server = zero.build_options('rust_analyzer', {}),
45 }
29 -- this will prevent zero from loading this server.
30 -- Java will be managed by nvim-jdtls, which wants to do things differently.
31 -- see ftplugin/java.lua
32 zero.build_options('jdtls', {})
47 -- this will prevent zero from loading this server.
48 -- Java will be managed by nvim-jdtls, which wants to do things differently.
49 -- see ftplugin/java.lua
50 zero.build_options('jdtls', {})
34 -- lua neovim lsp
35 luadev.setup {
36 lspconfig = zero.defaults.nvim_workspace(),
37 }
52 -- lua neovim lsp
53 luadev.setup {
54 lspconfig = zero.defaults.nvim_workspace(),
55 }
39 -- disable disco mode while typing
40 zero.setup_nvim_cmp {
41 completion = {
42 autocomplete = false,
43 },
44 }
57 -- disable disco mode while typing
58 zero.setup_nvim_cmp {
59 completion = {
60 autocomplete = false,
61 },
62 }
46 -- Format on Save when any LSP supports it.
47 local auto = require 'bugabinga.std.auto'
48 local null_opts = zero.build_options('null-ls', {
49 on_attach = function(client)
50 if client.server_capabilities.documentFormattingProvider then
51 auto 'format_buffer_on_write' {
52 description = 'Format the current buffer before writing.',
53 events = 'BufWritePre',
54 pattern = '<buffer>',
55 callback = function(context)
56 vim.lsp.buf.format()
57 vim.notify('Formatted ' .. context.file)
58 end,
59 }
60 end
61 end,
62 })
64 local null_opts = zero.build_options 'null-ls'
64 local formatting = null_ls.builtins.formatting
65 local diagnostics = null_ls.builtins.diagnostics
66 local code_actions = null_ls.builtins.code_actions
67 local hover = null_ls.builtins.hover
68 local completion = null_ls.builtins.completion
66 local formatting = null_ls.builtins.formatting
67 local diagnostics = null_ls.builtins.diagnostics
68 local code_actions = null_ls.builtins.code_actions
69 local hover = null_ls.builtins.hover
70 local completion = null_ls.builtins.completion
70 -- run diagnostics on save
71 local diagnostics_on_save = { method = null_ls.methods.DIAGNOSTICS_ON_SAVE }
72 null_ls.setup {
73 on_attach = null_opts.on_attach,
74 sources = {
75 formatting.black.with { extra_args = { '--fast' } },
76 formatting.stylua,
77 formatting.clang_format,
78 formatting.codespell,
79 formatting.jq,
80 formatting.protolint,
81 formatting.shellharden,
82 formatting.shfmt,
83 formatting.taplo,
72 -- run diagnostics on save
73 local diagnostics_on_save = { method = null_ls.methods.DIAGNOSTICS_ON_SAVE }
74 null_ls.setup {
75 on_attach = null_opts.on_attach,
76 sources = {
77 formatting.stylua,
78 formatting.clang_format,
79 formatting.codespell,
80 formatting.jq,
81 formatting.protolint,
82 formatting.shellharden,
83 formatting.shfmt,
84 formatting.taplo,
85 hover.dictionary,
86 hover.dictionary,
87 diagnostics.actionlint.with(diagnostics_on_save),
88 diagnostics.checkmake.with(diagnostics_on_save),
89 diagnostics.codespell.with(diagnostics_on_save),
90 diagnostics.editorconfig_checker.with(diagnostics_on_save).with { command = 'editorconfig-checker' },
91 diagnostics.gitlint.with(diagnostics_on_save),
92 diagnostics.protoc_gen_lint.with(diagnostics_on_save),
93 diagnostics.protolint.with(diagnostics_on_save),
94 diagnostics.selene.with(diagnostics_on_save).with {
95 -- null-ls determines the root in a too simplistic manner.
96 -- since my neovim configuration live inside my dotfiles, the dotfiles root
97 -- was taken. but i want the neovim config folder as root.
98 cwd = function(parameters)
99 local project = require 'bugabinga.std.project'
100 local root = project.determine_project_root({ name = 'selene.toml', weight = 10 }, parameters.root)
101 return root or parameters.root
102 end,
103 },
104 diagnostics.shellcheck.with(diagnostics_on_save),
105 diagnostics.tidy.with(diagnostics_on_save),
88 diagnostics.actionlint.with(diagnostics_on_save),
89 diagnostics.checkmake.with(diagnostics_on_save),
90 diagnostics.codespell.with(diagnostics_on_save),
91 diagnostics.editorconfig_checker.with(diagnostics_on_save).with { command = 'editorconfig-checker' },
92 diagnostics.gitlint.with(diagnostics_on_save),
93 diagnostics.protoc_gen_lint.with(diagnostics_on_save),
94 diagnostics.protolint.with(diagnostics_on_save),
95 diagnostics.selene.with(diagnostics_on_save).with {
96 -- null-ls determines the root in a too simplistic manner.
97 -- since my neovim configuration live inside my dotfiles, the dotfiles root
98 -- was taken. but i want the neovim config folder as root.
99 cwd = function(parameters)
100 local root = project.determine_project_root({ name = 'selene.toml', weight = 10 }, parameters.root)
101 return root or parameters.root
102 end,
103 },
104 diagnostics.shellcheck.with(diagnostics_on_save),
105 diagnostics.tidy.with(diagnostics_on_save),
107 code_actions.refactoring,
108 code_actions.shellcheck,
107 code_actions.refactoring,
108 code_actions.shellcheck,
110 completion.luasnip,
111 },
112 }
110 completion.luasnip,
111 },
112 }
114 zero.on_attach(function(client, buffer_number)
115 if client.name ~= 'null-ls' and not vim.b.lsp_attached then
116 navic.attach(client, buffer_number)
117 lsp_status.on_attach(client, buffer_number)
118 end
119 end)
114local function setup_keybinds_and_actions(client, buffer_number)
115 -- TODO: make format changed lines command
116 local capabilities = client.resolved_capabilities
117 if capabilities.document_formatting then
118 map {
119 description = 'Format buffer using LSP',
120 category = map.CATEGORY.EDITING,
121 mode = map.MODE.NORMAL,
122 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.F,
123 command = function()
124 vim.lsp.buf.format { bufnr = buffer_number }
125 vim.notify('Formatted ' .. vim.api.nvim_buf_get_name(buffer_number))
126 end,
127 }
128 end
129 if capabilities.document_range_formatting then
130 map {
131 description = 'Format range using LSP',
132 category = map.CATEGORY.EDITING,
133 mode = map.MODE.VISUAL,
134 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.F,
135 command = function()
136 vim.lsp.buf.range_formatting { bufnr = buffer_number }
137 vim.notify('Formatted range in ' .. vim.api.nvim_buf_get_name(buffer_number))
138 end,
139 }
140 end
141 --TODO: change some of these commands to telescoped versions
142 if capabilities.hover then
143 map {
144 description = 'Show Hover',
145 category = map.CATEGORY.VIEW,
146 mode = map.MODE.NORMAL,
147 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.K,
148 command = function()
149 vim.lsp.buf.hover()
150 end,
151 }
152 end
153 if capabilities.goto_definition then
154 map {
155 description = 'Go to Definition',
156 category = map.CATEGORY.NAVIGATION,
157 mode = map.MODE.NORMAL,
158 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.D,
159 command = function()
160 vim.lsp.buf.definition()
161 end,
162 }
163 end
164 if capabilities.declaration then
165 map {
166 description = 'Go to Declaration',
167 category = map.CATEGORY.NAVIGATION,
168 mode = map.MODE.NORMAL,
169 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.D .. map.KEY.D,
170 command = function()
171 vim.lsp.buf.declaration()
172 end,
173 }
174 end
175 if capabilities.implementation then
176 map {
177 description = 'Go to Implementation',
178 category = map.CATEGORY.NAVIGATION,
179 mode = map.MODE.NORMAL,
180 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.I,
181 command = function()
182 vim.lsp.buf.implementation()
183 end,
184 }
185 end
186 if capabilities.type_definition then
187 map {
188 description = 'Go to Type Definition',
189 category = map.CATEGORY.NAVIGATION,
190 mode = map.MODE.NORMAL,
191 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.T,
192 command = function()
193 vim.lsp.buf.type_definition()
194 end,
195 }
196 end
197 if capabilities.find_references then
198 map {
199 description = 'Go to References',
200 category = map.CATEGORY.NAVIGATION,
201 mode = map.MODE.NORMAL,
202 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.R,
203 command = function()
204 vim.lsp.buf.references()
205 end,
206 }
207 end
208 if capabilities.call_hierarchy then
209 map {
210 description = 'Go to Incoming Call',
211 category = map.CATEGORY.NAVIGATION,
212 mode = map.MODE.NORMAL,
213 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.C,
214 command = function()
215 vim.lsp.buf.incoming_calls()
216 end,
217 }
218 map {
219 description = 'Go to Outgoing Call',
220 category = map.CATEGORY.NAVIGATION,
221 mode = map.MODE.NORMAL,
222 keys = map.KEY.LEADER .. map.KEY.L .. map.KEY.C .. map.KEY.C,
223 command = function()
224 vim.lsp.buf.outgoing_calls()
225 end,
226 }
227 end
228 if capabilities.rename then
229 map {
230 description = 'Rename symbol',
231 category = map.CATEGORY.EDITING,
232 mode = map.MODE.NORMAL,
233 keys = map.KEY.F2,
234 command = function()
235 vim.lsp.buf.rename()
236 end,
237 }
238 end
239 if capabilities.code_action then
240 map {
241 description = 'Show code actions',
242 category = map.CATEGORY.VIEW,
243 mode = map.MODE.NORMAL,
244 keys = map.KEY.F4,
245 command = function()
246 vim.lsp.buf.code_action()
247 end,
248 }
249 map {
250 description = 'Show code actions in range',
251 category = map.CATEGORY.VIEW,
252 mode = map.MODE.VISUAL,
253 keys = map.KEY.F4,
254 command = function()
255 vim.lsp.buf.range_code_action()
256 end,
257 }
258 end
259 if capabilities.document_highlight then
260 -- this variable should technically be scoped to the current buffer.
261 -- how to do that?
262 local highlight_timer = nil
263 auto 'highlight_reference_under_cursor' {
264 {
265 description = 'Automatically highlight a symbol under cursor',
266 events = 'CursorHold',
267 pattern = '<buffer>',
268 command = function()
269 if not highlight_timer then
270 highlight_timer = vim.defer_fn(function()
271 vim.lsp.buf.document_highlight()
272 highlight_timer = nil
273 end, 866)
274 end
275 end,
276 },
277 {
278 description = 'Clear highlighted symbol under cursor',
279 events = { 'CursorMoved', 'CursorMovedI', 'InsertEnter' },
280 pattern = '<buffer>',
281 command = function()
282 if highlight_timer then
283 highlight_timer:close()
284 highlight_timer = nil
285 end
286 vim.lsp.buf.clear_references()
287 end,
288 },
289 }
290 end
291 end
121 zero.setup()
293 zero.on_attach(function(client, buffer_number)
294 if client.name ~= 'null-ls' and not vim.b.lsp_attached then
295 navic.attach(client, buffer_number)
296 lsp_status.on_attach(client, buffer_number)
297 setup_keybinds_and_actions(client, buffer_number)
298 end
299 end)
301 zero.setup()
302
122303end)

neovim/lua/bugabinga/move-code.lua

Modified

+3 / −3 text lines

4040 }
4141 map {
4242 description = 'Move line up',
43 category = map.CATEGORY.EDITING,
43 category = map.CATEGORY.EDITING,
4444 command = '<Plug>GoNSMUp',
4545 mode = map.MODE.NORMAL,
4646 keys = map.KEY.ALT_K,
7474 }
7575 map {
7676 description = 'Move block up',
77 category = map.CATEGORY.EDITING,
7877 command = '<Plug>GoVSMUp',
78 category = map.CATEGORY.EDITING,
7979 mode = map.MODE.VISUAL,
8080 keys = map.KEY.ALT_K,
8181 options = options,
8585 category = map.CATEGORY.EDITING,
8686 command = '<Plug>GoVSMRight',
8787 mode = map.MODE.VISUAL,
88 keys = map.KEY.ALT_K,
88 keys = map.KEY.ALT_L,
8989 options = options,
9090 }

neovim/lua/bugabinga/options/autocommands.lua

Modified

+2 / −2 text lines

44 description = 'briefly highlight yanked text',
55 events = 'TextYankPost',
66 pattern = '*',
7 callback = function()
7 command = function()
88 vim.highlight.on_yank { timeout = 500 }
99 end,
1313 description = 'Hide colorcolumn in buffers, that do not show source code.',
1414 events = { 'FileType' },
1515 pattern = 'Trouble,qf,help,toggleterm',
16 callback = function()
16 command = function()
1717 vim.opt_local.colorcolumn = {}
1818 end,

neovim/lua/bugabinga/options/ui.lua

Modified

+6 / −3 text lines

3636-- hide output of insert completion popup in status
3737vim.opt.shortmess:append 'c'
39-- hide cmd window to give status more room
40vim.opt.cmdheight = 0
39-- show cmd window to prevent jitter ui
40vim.opt.cmdheight = 1
4242-- do not conceal special characters by default. filestypes can enable this on demand.
4343vim.opt.conceallevel = 0
6868vim.opt.termguicolors = true
6969vim.opt.lazyredraw = true
71-- cursor
72vim.opt.guicursor = 'n-v-c-sm:block-Cursor,i-ci-ve:ver25-blinkon250,r-cr:hor20,o:hor50'
7174-- font
72vim.opt.guifont = 'BlexMono Nerd Font:h16:antialias=true'
75vim.opt.guifont = 'BlexMono Nerd Font:h11:antialias=true'
7477-- neovide only options
7578if vim.g.neovide then

neovim/lua/bugabinga/smooth-scroll.lua

Modified

+1 / −1 text lines

77 default_keymaps = false,
88 hide_cursor = true,
99 }
10 -- FIXME: weird. when using the Scroll function via lua directly, it does seemingly nothing...
10 -- weird. when using the Scroll function via lua directly, it does seemingly nothing...
1111 --
1212 -- Half-window movements:
1313 map {

neovim/lua/bugabinga/std/auto.lua

Modified

+24 / −17 text lines

11-- Wrapper over `vim.api.nvim_create_autocmd` for automatic grouping and idempotency.
22return function(group_name)
3 local group = vim.api.nvim_create_augroup(group_name, { clear = true })
4 return function(list_of_autocommands)
5 if list_of_autocommands.events then
6 list_of_autocommands = { list_of_autocommands }
7 end
8 for _, autocommand in pairs(list_of_autocommands) do
9 vim.api.nvim_create_autocmd(autocommand.events, {
10 desc = autocommand.description,
11 group = group,
12 pattern = autocommand.pattern,
13 -- command and callback are mutually exclusive.
14 -- one of them has to be nil
15 command = autocommand.command,
16 callback = autocommand.callback,
17 })
18 end
19 end
3 local group = vim.api.nvim_create_augroup(group_name, { clear = true })
4 return function(list_of_autocommands)
5 if list_of_autocommands.events then
6 list_of_autocommands = { list_of_autocommands }
7 end
8 for _, autocommand in pairs(list_of_autocommands) do
9 -- command and callback are mutually exclusive.
10 -- one of them has to be nil
11 local command = nil
12 local callback = nil
13 if type(autocommand.command) == 'function' then
14 callback = autocommand.command
15 else
16 command = autocommand.command
17 end
18 vim.api.nvim_create_autocmd(autocommand.events, {
19 desc = autocommand.description,
20 group = group,
21 pattern = autocommand.pattern,
22 command = command,
23 callback = callback,
24 })
25 end
26 end
2027end

neovim/lua/bugabinga/std/icon.lua

Added
new file mode 100644

+19 / −0 text lines

1local want = require 'bugabinga.std.want'
2
3local function get_icon(icon_name)
4 return want { 'nvim-web-devicons' } (function(devicons)
5 return devicons.get_icon(icon_name)
6 end)
7end
8
9 --TODO: fill up those icons
10return setmetatable({
11 FILE = {},
12 UI = {},
13 DOCUMENT = {},
14 MISC = {},
15}, {
16 __call = function(_, ...)
17 return get_icon(...)
18 end,
19})

neovim/lua/bugabinga/std/keymap.lua

Modified

+20 / −3 text lines

5454 CONTROL_D = '<C-d>',
5555 CONTROL_F = '<C-f>',
5656 CONTROL_U = '<C-u>',
57 SHIFT_G = 'G',
58 SHIFT_N = 'N',
59 CONTROL_SHIFT_F = '<C-F>',
5760 ALT_H = '<A-h>',
5861 ALT_J = '<A-j>',
5962 ALT_K = '<A-k>',
6265 ALT_SHIFT_J = '<A-J>',
6366 ALT_SHIFT_K = '<A-K>',
6467 ALT_SHIFT_L = '<A-L>',
68 F2 = '<F2>',
69 F4 = '<F4>',
70 F6 = '<F6>',
71 F7 = '<F7>',
72 F8 = '<F8>',
6573 F12 = '<F12>',
6674 CARET = '^',
6775 DOLLAR = '$',
7179 CLOSE_CURLY_BRACKET = '}',
7280 ZERO = '0',
7381 B = 'b',
82 C = 'c',
83 D = 'd',
7484 E = 'e',
75 J = 'j',
85 F = 'f',
7686 G = 'g',
87 I = 'i',
88 J = 'j',
89 L = 'l',
7790 N = 'n',
7891 K = 'k',
7992 P = 'p',
93 R = 'r',
94 S = 's',
8095 T = 't',
81 SHIFT_G = 'G',
82 SHIFT_N = 'N',
96 V = 'v',
8397 },
8498 COMMAND = {
8599 NOP = function() end,
91105 VIEW = 'view',
92106 SEARCH = 'search',
93107 SCROLL = 'scroll',
108 PROBLEMS = 'problems',
109 LSP = 'lsp',
110 VERSION_CONTROL = 'vcs',
94111 },
95112}, {
96113 __call = function(_, ...)

neovim/lua/bugabinga/terminal.lua

Modified

+37 / −37 text lines

11local auto = require 'bugabinga.std.auto'
22local want = require 'bugabinga.std.want'
33--FIXME use keymap facade
4want { 'toggleterm' }(function(toggleterm)
5 toggleterm.setup {
6 size = 20,
7 open_mapping = [[<LEADER>t]],
8 hide_numbers = true,
9 shade_filetypes = {},
10 shade_terminals = true,
11 shading_factor = 2,
12 start_in_insert = true,
13 insert_mappings = false,
14 persist_size = true,
15 direction = 'float',
16 close_on_exit = true,
17 shell = vim.o.shell,
18 float_opts = {
19 border = 'curved',
20 winblend = 0,
21 highlights = {
22 border = 'Normal',
23 background = 'Normal',
24 },
25 },
26 }
4want { 'toggleterm' } (function(toggleterm)
5 toggleterm.setup {
6 size = 20,
7 open_mapping = [[<LEADER>t]],
8 hide_numbers = true,
9 shade_filetypes = {},
10 shade_terminals = true,
11 shading_factor = 2,
12 start_in_insert = true,
13 insert_mappings = false,
14 persist_size = true,
15 direction = 'float',
16 close_on_exit = true,
17 shell = vim.o.shell,
18 float_opts = {
19 border = 'curved',
20 winblend = 0,
21 highlights = {
22 border = 'Normal',
23 background = 'Normal',
24 },
25 },
26 }
28 local function set_terminal_keymaps()
29 local opts = { noremap = true }
30 vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
31 vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
32 vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
33 vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
34 vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
35 end
28 local function set_terminal_keymaps()
29 local opts = { noremap = true }
30 vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
31 vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
32 vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
33 vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
34 vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
35 end
37 auto 'set_terminal_keymaps' {
38 description = 'Set more natural keybindings in terminal',
39 events = 'TermOpen',
40 pattern = 'term://*',
41 callback = set_terminal_keymaps,
42 }
37 auto 'set_terminal_keymaps' {
38 description = 'Set more natural keybindings in terminal',
39 events = 'TermOpen',
40 pattern = 'term://*',
41 command = set_terminal_keymaps,
42 }
4343end)

neovim/lua/bugabinga/treesitter.lua

Modified

+188 / −142 text lines

1local auto = require 'bugabinga.std.auto'
12local want = require 'bugabinga.std.want'
3
24want {
3 'nvim-treesitter.install',
4 'nvim-treesitter.configs',
5 'nvim-treesitter.parsers',
6 'hlargs',
7 'neogen',
8}(function(install, configs, parsers, hlargs, neogen)
9 install.compilers = { 'zig cc', 'clang', 'gcc', 'cl', 'cc', vim.fn.getenv 'CC' }
10 install.prefer_git = true
5 'nvim-treesitter.install',
6 'nvim-treesitter.configs',
7 'nvim-treesitter.parsers',
8 'hlargs',
9 'neogen',
10} (function(install, configs, parsers, hlargs, neogen)
11 install.compilers = { 'zig cc', 'clang', 'gcc', 'cl', 'cc', vim.fn.getenv 'CC' }
12 install.prefer_git = true
12 configs.setup {
13 -- A list of parser names, or "all"
14 ensure_installed = 'all',
15 -- Install parsers synchronously (only applied to `ensure_installed`)
16 sync_install = true,
17 -- List of parsers to ignore installing (for "all")
18 ignore_install = {},
14 configs.setup {
15 -- A list of parser names, or "all"
16 -- FIXME: temporarily deactivated, because i am offline
17 -- ensure_installed = 'all',
18 -- Install parsers synchronously (only applied to `ensure_installed`)
19 sync_install = true,
20 -- Automatically install missing parsers when entering buffer
21 auto_install = true,
22 -- List of parsers to ignore installing (for "all")
23 ignore_install = {},
20 highlight = {
21 -- `false` will disable the whole extension
22 enable = true,
23 disable = {},
25 highlight = {
26 -- `false` will disable the whole extension
27 enable = true,
28 disable = {},
25 -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
26 -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
27 -- Using this option may slow down your editor, and you may see some duplicate highlights.
28 -- Instead of true it can also be a list of languages
29 additional_vim_regex_highlighting = false,
30 },
31 incremental_selection = {
32 enable = true,
33 keymaps = {
34 init_selection = 'gnn',
35 node_incremental = 'grn',
36 scope_incremental = 'grc',
37 node_decremental = 'grm',
38 },
39 },
40 -- indent on = with TS
41 indent = {
42 enable = true,
43 },
44 -- These features are mostly useful when there is treesitter parser, but no
45 -- LSP.
46 -- FIXME: harmonize the keybinds with LSP equivalents
47 refactor = 'all',
48 textsubjects = {
49 enable = true,
50 prev_selection = '<Down>', -- (Optional) keymap to select the previous selection
51 keymaps = {
52 ['<Up>'] = 'textsubjects-smart',
53 ['<Right>'] = 'textsubjects-container-outer',
54 ['<Left>'] = 'textsubjects-container-inner',
55 },
56 },
57 textobjects = {
58 select = {
59 enable = true,
60 -- Automatically jump forward to textobj, similar to targets.vim
61 lookahead = true,
62 keymaps = {
63 -- You can use the capture groups defined in textobjects.scm
64 ['af'] = '@function.outer',
65 ['if'] = '@function.inner',
66 ['ac'] = '@class.outer',
67 ['ic'] = '@class.inner',
68 },
69 },
70 swap = {
71 enable = true,
72 swap_next = {
73 ['<leader>a'] = '@parameter.inner',
74 },
75 swap_previous = {
76 ['<leader>A'] = '@parameter.inner',
77 },
78 },
79 move = {
80 enable = true,
81 set_jumps = true, -- whether to set jumps in the jumplist
82 goto_next_start = {
83 [']m'] = '@function.outer',
84 [']]'] = '@class.outer',
85 },
86 goto_next_end = {
87 [']M'] = '@function.outer',
88 [']['] = '@class.outer',
89 },
90 goto_previous_start = {
91 ['[m'] = '@function.outer',
92 ['[['] = '@class.outer',
93 },
94 goto_previous_end = {
95 ['[M'] = '@function.outer',
96 ['[]'] = '@class.outer',
97 },
98 },
99 lsp_interop = {
100 enable = true,
101 border = 'none',
102 peek_definition_code = {
103 ['<leader>df'] = '@function.outer',
104 ['<leader>dc'] = '@class.outer',
105 },
106 },
107 },
108 playground = {
109 enable = true,
110 disable = {},
111 updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
112 persist_queries = false, -- Whether the query persists across vim sessions
113 keybindings = {
114 toggle_query_editor = 'o',
115 toggle_hl_groups = 'i',
116 toggle_injected_languages = 't',
117 toggle_anonymous_nodes = 'a',
118 toggle_language_display = 'I',
119 focus_language = 'f',
120 unfocus_language = 'F',
121 update = 'R',
122 goto_node = '<cr>',
123 show_help = '?',
124 },
125 },
126 context_commentstring = {
127 enable = true,
128 },
129 -- autoclose and rename tags
130 autotag = {
131 enable = true,
132 },
133 }
30 -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
31 -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
32 -- Using this option may slow down your editor, and you may see some duplicate highlights.
33 -- Instead of true it can also be a list of languages
34 additional_vim_regex_highlighting = false,
35 },
36 incremental_selection = {
37 enable = true,
38 keymaps = {
39 init_selection = 'gnn',
40 node_incremental = 'grn',
41 scope_incremental = 'grc',
42 node_decremental = 'grm',
43 },
44 },
45 -- indent on = with TS
46 indent = {
47 enable = true,
48 },
49 -- These features are mostly useful when there is treesitter parser, but no
50 -- LSP.
51 -- FIXME: harmonize the keybinds with LSP equivalents
52 refactor = 'all',
53 textsubjects = {
54 enable = true,
55 prev_selection = '<Down>', -- (Optional) keymap to select the previous selection
56 keymaps = {
57 ['<Up>'] = 'textsubjects-smart',
58 ['<Right>'] = 'textsubjects-container-outer',
59 ['<Left>'] = 'textsubjects-container-inner',
60 },
61 },
62 textobjects = {
63 select = {
64 enable = true,
65 -- Automatically jump forward to textobj, similar to targets.vim
66 lookahead = true,
67 keymaps = {
68 -- You can use the capture groups defined in textobjects.scm
69 ['af'] = '@function.outer',
70 ['if'] = '@function.inner',
71 ['ac'] = '@class.outer',
72 ['ic'] = '@class.inner',
73 },
74 },
75 swap = {
76 enable = true,
77 swap_next = {
78 ['<leader>a'] = '@parameter.inner',
79 },
80 swap_previous = {
81 ['<leader>A'] = '@parameter.inner',
82 },
83 },
84 move = {
85 enable = true,
86 set_jumps = true, -- whether to set jumps in the jumplist
87 goto_next_start = {
88 [']m'] = '@function.outer',
89 [']]'] = '@class.outer',
90 },
91 goto_next_end = {
92 [']M'] = '@function.outer',
93 [']['] = '@class.outer',
94 },
95 goto_previous_start = {
96 ['[m'] = '@function.outer',
97 ['[['] = '@class.outer',
98 },
99 goto_previous_end = {
100 ['[M'] = '@function.outer',
101 ['[]'] = '@class.outer',
102 },
103 },
104 lsp_interop = {
105 enable = true,
106 border = 'rounded',
107 peek_definition_code = {
108 ['<leader>df'] = '@function.outer',
109 ['<leader>dc'] = '@class.outer',
110 },
111 },
112 },
113 playground = {
114 enable = true,
115 disable = {},
116 updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
117 persist_queries = false, -- Whether the query persists across vim sessions
118 keybindings = {
119 toggle_query_editor = 'o',
120 toggle_hl_groups = 'i',
121 toggle_injected_languages = 't',
122 toggle_anonymous_nodes = 'a',
123 toggle_language_display = 'I',
124 focus_language = 'f',
125 unfocus_language = 'F',
126 update = 'R',
127 goto_node = '<cr>',
128 show_help = '?',
129 },
130 },
131 context_commentstring = {
132 enable = true,
133 },
134 -- autoclose and rename tags
135 autotag = {
136 enable = true,
137 },
138 }
135 parsers.get_parser_configs().just = {
136 install_info = {
137 url = 'https://github.com/IndianBoy42/tree-sitter-just', -- local path or git repo
138 files = { 'src/parser.c', 'src/scanner.cc' },
139 branch = 'main',
140 },
141 maintainers = { '@IndianBoy42' },
142 }
140 parsers.get_parser_configs().just = {
141 install_info = {
142 url = 'https://github.com/IndianBoy42/tree-sitter-just', -- local path or git repo
143 files = { 'src/parser.c', 'src/scanner.cc' },
144 branch = 'main',
145 },
146 maintainers = { '@IndianBoy42' },
147 }
144 -- highlight function arguments
145 -- TODO: define color
146 hlargs.setup()
149 -- highlight function arguments
150 -- TODO: define color
151 hlargs.setup()
148 -- generate doc comment annotations
149 -- TODO: setup keybind
150 neogen.setup()
153 -- generate doc comment annotations
154 -- TODO: setup keybind
155 neogen.setup{
156 snippet_engine = 'luasnip',
157 }
159 map {
160 description = 'Generate Doc Comment for Function',
161 category = map.CATEGORY.EDITING,
162 mode = map.MODE.NORMAL,
163 keys = map.KEY.LEADER .. map.KEY.N .. map.KEY.F,
164 command = function() neogen.generate{ type = 'func'} end,
165 }
167 -- FIXME: this aucmd needs to be restricted to buffers where treesitter is loaded
168 -- Treesitter highlights tend to highlight syntax errors immediately.
169 -- But that i find distracting while typing.
170 -- Disable the error highlight while typing, but keep it in normal mode.
171 auto 'disable_error_highlight_while_typing' {
172 {
173 description = 'Disable the @error highlight while in Insert mode',
174 events = 'InsertEnter',
175 pattern = '*',
176 command = function()
177 want { 'nvim-treesitter.highlight' } (function(highlight)
178 pcall(highlight.stop)
179 pcall(highlight.set_custom_captures, { error = 'None' })
180 pcall(highlight.start)
181 end)
182 end,
183 },
184 {
185 description = 'Enable the @error highlight while in Normal mode',
186 events = 'InsertLeave',
187 pattern = '*',
188 command = function()
189 want { 'nvim-treesitter.highlight' } (function(highlight)
190 pcall(highlight.stop)
191 pcall(highlight.set_custom_captures, { error = 'TSError' })
192 pcall(highlight.start)
193 end)
194 end,
195 },
196 }
151197end)

river/init

Modified

+2 / −1 text lines

1919ctrl="Control"
2121riverctl map normal $super Return spawn wezterm
22riverctl map normal $super+Shift Return spawn foot
2223riverctl map normal $super B spawn firefox
23riverctl map normal $super asciicircum spawn 'fuzzel --terminal "wezterm start"'
24riverctl map normal $super grave spawn 'fuzzel --terminal "wezterm start"'
2526# close the focused view
2627riverctl map normal $super Q close