repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim: clean up lsp config and add terminal and patterns

a38f4ab5e449e5eaed485fbc3b17122659fffdb4

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (27)

neovim/README.md

Modified
49 49 # todo
51 51 * neoterm keymaps
52 -* TODO highlights
53 52 * learn mini.operators
54 53 * create skeleton-plugin for default file content based on file type
55 54 (BufNewFile?)

neovim/init.lua

Modified
9 9 -- ▀ ▀
11 11 -- Setup debug mode
12 -require 'std.dbg'.toggle()
12 +vim.g.bugabinga_debug_mode = true
14 14 local start_time = vim.uv.hrtime()
15 15 local auto = require 'std.auto'
62 62 require 'bugabinga.surround'
63 63 require 'bugabinga.textobjects'
64 64 require 'bugabinga.key_preview'
65 +require 'bugabinga.patterns'
66 +require 'bugabinga.terminal'
66 68 require 'bugabinga.incubator'

neovim/lua/bugabinga/diagnostic.lua

Modified
18 18 local diagnostic = vim.diagnostic
19 -diagnostic.enable( false )
19 +diagnostic.enable(false)
21 21 auto 'disable_diagnostic_initially' {
22 22 description = 'Disable Diagnostics initially, when attaching an LSP client to a buffer',
23 23 events = 'LspAttach',
24 - command = function () diagnostic.enable( false, { bufnr = 0 } ) end,
24 + command = function() diagnostic.enable(false, { bufnr = 0 }) end,
27 -local diagnostic_format = function ( context )
28 - return string.format( '%s: %s', display_name[context.severity], context.message )
27 +local diagnostic_format = function(context)
28 + return string.format('%s: %s', display_name[context.severity], context.message)
31 -local prefix_format = function ( context, index, total )
32 - return string.format( '%s/%s %s %s ', index, total, context.source, diagnostic_icons[context.severity] ),
33 - 'DiagnosticVirtualText' .. display_name[context.severity]
31 +local prefix_format = function(context, index, total)
32 + return string.format('%s/%s %s %s ', index, total, context.source, diagnostic_icons[context.severity]),
33 + 'DiagnosticVirtualText' .. display_name[context.severity]
36 36 diagnostic.config {
50 50 prefix = prefix_format,
52 52 update_in_insert = false,
53 - signs = true,
53 + signs = {
54 + text = {
55 + [vim.diagnostic.severity.ERROR] = diagnostic_icons.error,
56 + [vim.diagnostic.severity.WARN] = diagnostic_icons.warn,
57 + [vim.diagnostic.severity.INFO] = diagnostic_icons.info,
58 + [vim.diagnostic.severity.HINT] = diagnostic_icons.hint,
59 + }
60 + },
54 61 severity_sort = true,
57 -local sign = function ( options )
58 - vim.fn.sign_define( options.name, {
59 - text = options.text,
60 - texthl = options.name,
61 - numhl = nil,
62 - culhl = nil,
63 - linehl = nil,
64 - } )
65 -end
67 -sign { name = 'DiagnosticSignError', text = diagnostic_icons.error }
68 -sign { name = 'DiagnosticSignWarn', text = diagnostic_icons.warn }
69 -sign { name = 'DiagnosticSignHint', text = diagnostic_icons.hint }
70 -sign { name = 'DiagnosticSignInfo', text = diagnostic_icons.info }
72 64 -- TODO: move to togglers
73 65 map.normal {
74 66 description = 'Toggle diagnostics',
75 67 category = 'diagnostic',
76 68 keys = '<leader>td',
77 - command = function ()
69 + command = function()
78 70 if not diagnostic.is_enabled() then
79 71 diagnostic.enable()
80 72 vim.notify 'Enabling Diagnostics'
82 - diagnostic.enable( false )
74 + diagnostic.enable(false)
83 75 vim.notify 'Disabling Diagnostics'
98 90 keys = 'HH',
99 91 command = diagnostic.setqflist,
102 -local show_diagnostics_in_buffer = function ()
103 - local builtin = require 'telescope.builtin'
104 - builtin.diagnostics { bufnr = 0 }
105 -end
107 -map.normal {
108 - description = 'Show all diagnostics in buffer',
109 - category = 'diagnostic',
110 - keys = '<F6>',
111 - command = show_diagnostics_in_buffer,
114 -local show_diagnostics_in_workspace = function ()
115 - local builtin = require 'telescope.builtin'
116 - builtin.diagnostics()
117 -end
119 -map.normal {
120 - description = 'Show all diagnostics in workspace',
121 - category = 'diagnostic',
122 - keys = '<F6><F6>',
123 - command = show_diagnostics_in_workspace,
126 --- a little debug helper to show all kinds of diagnostics
128 -local dia = function ( severity, line )
129 - local ns = vim.api.nvim_create_namespace( 'test' .. tostring( severity ) )
130 - local bufnr = vim.api.nvim_get_current_buf()
131 - local options = {
132 - bufnr = bufnr,
133 - lnum = line,
134 - end_lnum = line,
135 - col = 0,
136 - severity = severity,
137 - message = 'This is a test ' .. tostring( severity ) .. ' diagnostic',
138 - }
140 - vim.diagnostic.set( ns, bufnr, { options } )
141 - vim.diagnostic.show( ns, bufnr, { options } )
142 -end
144 -local send_dia = function ()
145 - dia( vim.diagnostic.severity.ERROR, 1 )
146 - dia( vim.diagnostic.severity.WARN, 2 )
147 - dia( vim.diagnostic.severity.INFO, 3 )
148 - dia( vim.diagnostic.severity.HINT, 4 )
149 -end
151 -vim.g.send_dia = send_dia

neovim/lua/bugabinga/lsp.lua

Added
new file mode 100644
1 +local puk = require 'std.puk'
2 +local project = require 'std.project'
3 +local dbg = require 'std.dbg'
4 +local icon = require 'std.icon'
5 +local map = require 'std.map'
6 +local auto = require 'std.auto'
7 +local table = require 'std.table'
8 +local localrc = require 'std.localrc'
10 +if dbg.get() then
11 + vim.lsp.set_log_level('debug')
12 +end
14 +local language_servers = {
15 + lua_ls = {
16 + root_dir = project.find_lua_project_root,
17 + settings = {
18 + Lua = {
19 + hint = { enable = true, setType = true, },
20 + telemetry = { enable = false, },
21 + },
22 + },
23 + },
24 + jdtls = {
25 + root_dir = project.find_java_project_root,
26 + settings = {
27 + java = {
28 + signatureHelp = { enabled = true, },
29 + sources = {
30 + autobuild = { enabled = true, },
31 + signatureHelp = { enabled = true, },
32 + saveActions = { origanizeImports = true, },
33 + organizeImports = {
34 + starThreshold = 9999,
35 + staticStarThreshold = 9999,
36 + },
37 + codeGeneration = {
38 + toString = {
39 + template = '${object.className}{${member.name()}=${member.value()}, ${otherMembers}}',
40 + },
41 + hashCodeEquals = { useJava7Objects = true, },
42 + useBlocks = true,
43 + },
44 + eclipse = { downloadSources = true, },
45 + },
46 + configuration = {
47 + updateBuildConfiguration = 'interactive',
48 + },
49 + maven = { downloadSources = true, },
50 + implementationsCodeLens = { enabled = true, },
51 + referencesCodeLens = { enabled = true, },
52 + references = { includeDecompiledSources = true, },
53 + inlayHints = { parameterNames = { enabled = 'all', }, },
54 + format = { enabled = true, },
55 + }
56 + },
57 + },
58 + zls = { root_dir = project.find_zig_project_root, },
59 + ziggy = { root_dir = project.find_zig_project_root, },
60 + ziggy_schema = { root_dir = project.find_zig_project_root, },
61 + harper_ls = {
62 + settings = {
63 + ["harper-ls"] = {
64 + linters = {
65 + spell_check = true,
66 + spelled_numbers = true,
67 + an_a = true,
68 + sentence_capitalization = false,
69 + unclosed_quotes = true,
70 + wrong_quotes = true,
71 + long_sentences = true,
72 + repeated_words = true,
73 + spaces = false,
74 + matcher = true,
75 + correct_number_suffix = true,
76 + number_suffix_capitalization = true,
77 + multiple_sequential_pronouns = true,
78 + linking_verbs = true,
79 + avoid_curses = true,
80 + terminating_conjunctions = true
81 + },
82 + codeActions = {
83 + forceStable = true
84 + },
85 + }
86 + }
87 + },
88 + asm_lsp = {},
89 + clangd = {},
90 + denols = {},
91 + dotls = {},
92 + docker_compose_language_service = {},
93 + dockerls = {},
94 + ast_grep = {},
95 + cssls = {},
96 + css_variables = {},
97 + contextive = {},
98 + emmet_language_server = {},
99 + gopls = {},
100 + gradle_ls = {},
101 + html = {},
102 + htmx = {},
103 + hyprls = {},
104 + jsonls = {},
105 + lemminx = {},
106 + ltex = {},
107 + marksman = {},
108 + markdown_oxide = {},
109 + nil_ls = {},
110 + nixd = {},
111 + nushell = {},
112 + ocamllsp = {},
113 + protols = {},
114 + roc_ls = {},
115 + rust_analyzer = {},
116 + statix = {},
117 + superhtml = {},
118 + taplo = {},
119 + ts_ls = {},
120 + zk = {},
123 +local lspconfig = puk 'lspconfig'
124 +for server, config in pairs(language_servers) do
125 + local capabilities = vim.lsp.protocol.make_client_capabilities()
126 + config.capabilities = require('bugabinga.completion').get_lsp_capabilities(config.capabilities)
127 + capabilities = table.extend('force', capabilities, config.capabilities)
128 + local settings = config.settings or {}
129 + -- TODO reimplement local settings overrides
130 + -- local settings_override = local_settings(server) or {}
131 + -- config.settings = table.extend('force', settings, settings_override)
132 + lspconfig[server].setup(config)
133 +end
135 +local lsp_attach = function(args)
136 + local bufnr = args.buf
137 + local client_id = args.data.client_id
138 + local client = vim.lsp.get_client_by_id(client_id)
139 + if not client then return end
141 + vim.lsp.completion.enable(true, client_id, bufnr)
143 + if client.server_capabilities.inlayHintProvider then
144 + map.normal {
145 + description = 'Toggle inlay hints',
146 + category = 'lsp',
147 + buffer = bufnr,
148 + keys = '<leader>ti',
149 + command = function()
150 + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
151 + end,
153 + end
154 +end
156 +auto 'lsp' {
157 + description = 'lsp: client attached to buffer',
158 + events = 'LspAttach',
159 + command = lsp_attach,
162 +local completion_icons = {
163 + Class = icon.class,
164 + Color = icon.color,
165 + Constant = icon.constant,
166 + Constructor = icon.constructor,
167 + Enum = icon.enum,
168 + EnumMember = icon.enum_member,
169 + Field = icon.field,
170 + File = icon.file,
171 + Folder = icon.folder,
172 + Function = icon['function'],
173 + Interface = icon.interface,
174 + Keyword = icon.keyword,
175 + Method = icon.method,
176 + Module = icon.module,
177 + Property = icon.property,
178 + Snippet = icon.snippet,
179 + Struct = icon.struct,
180 + Text = icon.text,
181 + Unit = icon.unit,
182 + Value = icon.value,
183 + Variable = icon.variable,
186 +local completion_kinds = vim.lsp.protocol.CompletionItemKind
187 +for i, kind in ipairs(completion_kinds) do
188 + completion_kinds[i] = completion_icons[kind] or kind
189 +end

neovim/lua/bugabinga/lsp/clients/asm.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'asm-lsp',
5 - command = 'asm-lsp',
6 - filetypes = { 'asm', 'vmasm', },
7 - root_dir = project.find_vcs_project_root,
8 - single_file_support = true,
9 - workspaces = false,
10 -}

neovim/lua/bugabinga/lsp/clients/c.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'clangd',
5 - root_dir = project.find_vcs_project_root,
6 - capabilities = {
7 - textDocument = {
8 - completion = {
9 - editsNearCursor = true,
10 - },
11 - },
12 - offsetEncoding = { 'utf-8', 'utf-16', },
13 - },
14 -}

neovim/lua/bugabinga/lsp/clients/graphviz.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'dot-lsp',
5 - command = { 'dot-language-server', '--stdio', },
6 - filetypes = 'dot',
7 - root_dir = project.find_vcs_project_root,
8 - single_file_support = true,
9 - workspaces = false,
10 -}

neovim/lua/bugabinga/lsp/clients/init.lua

Deleted
deleted file mode 100644
1 -return {
2 - require 'bugabinga.lsp.clients.java',
3 - require 'bugabinga.lsp.clients.lua',
4 - require 'bugabinga.lsp.clients.asm',
5 - require 'bugabinga.lsp.clients.c',
6 - require 'bugabinga.lsp.clients.graphviz',
7 - require 'bugabinga.lsp.clients.markdown',
8 - require 'bugabinga.lsp.clients.nu',
9 - require 'bugabinga.lsp.clients.rust',
10 - require 'bugabinga.lsp.clients.toml',
11 - require 'bugabinga.lsp.clients.vim',
12 - require 'bugabinga.lsp.clients.xml',
13 - require 'bugabinga.lsp.clients.zig',
14 -}

neovim/lua/bugabinga/lsp/clients/java.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
2 -local auto = require 'std.auto'
4 -local java_settings = {
5 - signatureHelp = { enabled = true, },
6 - sources = {
7 - autobuild = { enabled = true, },
8 - signatureHelp = { enabled = true, },
9 - saveActions = { origanizeImports = true, },
10 - organizeImports = {
11 - starThreshold = 9999,
12 - staticStarThreshold = 9999,
13 - },
14 - codeGeneration = {
15 - toString = {
16 - template = '${object.className}{${member.name()}=${member.value()}, ${otherMembers}}',
17 - },
18 - hashCodeEquals = { useJava7Objects = true, },
19 - useBlocks = true,
20 - },
21 - eclipse = { downloadSources = true, },
22 - },
23 - configuration = {
24 - updateBuildConfiguration = 'interactive',
25 - },
26 - maven = { downloadSources = true, },
27 - implementationsCodeLens = { enabled = true, },
28 - referencesCodeLens = { enabled = true, },
29 - references = { includeDecompiledSources = true, },
30 - inlayHints = { parameterNames = { enabled = 'all', }, },
31 - format = { enabled = true, },
32 -}
34 -local on_attach = function ()
35 - vim.lsp.codelens.refresh()
36 - auto 'refresh_codelens' {
37 - events = 'BufWritePost',
38 - description = 'Refreshes LSP CodeLens after java file is written.',
39 - pattern = '*.java',
40 - command = function () pcall( vim.lsp.codelens.refresh ) end,
41 - }
42 -end
44 -return {
45 - name = 'jdtls',
46 - filetypes = 'java',
47 - command = 'jdtls',
48 - root_dir = project.find_java_project_root,
49 - single_file_support = true,
50 - workspaces = true,
51 - settings = { java = java_settings, },
52 - on_attach = on_attach,
53 -}

neovim/lua/bugabinga/lsp/clients/ltex.lua

Deleted
deleted file mode 100644
1 --- TODO
2 -return {}

neovim/lua/bugabinga/lsp/clients/lua.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'LuaLS',
5 - root_dir = project.find_lua_project_root,
6 - settings = {
7 - Lua = {
8 - hint = { enable = true, setType = true, },
9 - telemetry = { enable = false, },
10 - },
11 - },
12 -}

neovim/lua/bugabinga/lsp/clients/markdown.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'marksman',
5 - command = { 'marksman', 'server', },
6 - filetypes = 'markdown',
7 - root_dir = function ( path )
8 - local markers = {
9 - { name = '.marksman.toml', weight = 10, },
10 - }
11 - return project.find_project_root( path, markers )
12 - end,
13 - single_file_support = true,
14 - workspaces = false,
15 -}

neovim/lua/bugabinga/lsp/clients/nu.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'nulsp',
5 - command = { 'nu', '--lsp' },
6 - filetypes = { 'nu' },
7 - root_dir = project.find_project_root,
8 - single_file_support = true,
9 - workspaces = false,
10 -}

neovim/lua/bugabinga/lsp/clients/rust.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 ---TODO: can this be used as general template for all kinds of lsp commands?
4 -local function reload_workspace( bufnr )
5 - local clients = vim.lsp.get_active_clients { name = 'rust_analyzer', bufnr = bufnr, }
6 - for _, client in ipairs( clients ) do
7 - vim.notify 'Reloading Cargo Workspace'
8 - client.request( 'rust-analyzer/reloadWorkspace', nil, function ( err )
9 - if err then
10 - error( tostring( err ) )
11 - end
12 - vim.notify 'Cargo workspace reloaded'
13 - end, 0 )
14 - end
15 -end
17 -local is_descendant = function ( root, path )
18 - if not path then return false end
20 - for directory in vim.fs.parents( path ) do
21 - if vim.fs.normalize( root ) == vim.fs.normalize( directory ) then return true end
22 - end
24 - return false
25 -end
27 -local function is_library( fname )
28 - local user_home = vim.fs.normalize( vim.env.HOME )
29 - local cargo_home = os.getenv 'CARGO_HOME' or vim.fs.joinpath( user_home, '.cargo' )
30 - local registry = vim.fs.joinpath( cargo_home, 'registry', 'src' )
31 - local git_registry = vim.fs.joinpath( cargo_home, 'git', 'checkouts' )
33 - local rustup_home = os.getenv 'RUSTUP_HOME' or vim.fs.joinpath( user_home, '.rustup' )
34 - local toolchains = vim.fs.joinpath( rustup_home, 'toolchains' )
36 - for _, item in ipairs { toolchains, registry, git_registry, } do
37 - if is_descendant( item, fname ) then
38 - local clients = vim.lsp.get_active_clients { name = 'rust_analyzer', }
39 - return #clients > 0 and clients[#clients].config.root_dir or nil
40 - end
41 - end
42 -end
45 -return {
46 - name = 'rust-analyzer',
47 - command = 'rust-analyzer',
48 - filetypes = 'rust',
49 - root_dir = function ( path )
50 - local library_root = is_library( path )
51 - if library_root then return library_root end
52 - return project.find_rust_project_root( path )
53 - end,
54 - capabilities = {
55 - experimental = {
56 - serverStatusNotification = true,
57 - },
58 - },
59 - commands = {
60 - CargoReload = {
61 - function ()
62 - reload_workspace( 0 )
63 - end,
64 - description = 'Reload current cargo workspace',
65 - },
66 - },
67 -}

neovim/lua/bugabinga/lsp/clients/toml.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'taplo',
5 - command = { 'taplo', 'lsp', 'stdio', },
6 - root_dir = project.find_vcs_project_root,
7 - filetypes = 'toml',
8 - single_file_support = true,
9 - workspaces = false,
11 -}

neovim/lua/bugabinga/lsp/clients/vim.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'vim-lsp',
5 - command = { 'vim-language-server', '--stdio', },
6 - filetypes = 'vim',
7 - root_dir = project.find_vcs_project_root,
8 - single_file_support = true,
9 - init_options = {
10 - isNeovim = true,
11 - iskeyword = '@,48-57,_,192-255,-#',
12 - vimruntime = '',
13 - runtimepath = '',
14 - diagnostic = { enable = true, },
15 - indexes = {
16 - runtimepath = true,
17 - gap = 100,
18 - count = 3,
19 - projectRootPatterns = { 'runtime', 'nvim', '.git', 'autoload', 'plugin', },
20 - },
21 - suggest = { fromVimruntime = true, fromRuntimepath = true, },
22 - },
23 -}

neovim/lua/bugabinga/lsp/clients/xml.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'lemminx',
5 - command = 'lemminx',
6 - filetypes = { 'xml', 'xsd', 'xsl', 'xslt', 'svg', },
7 - root_dir = project.find_vcs_project_root,
8 - single_file_support = true,
9 -}

neovim/lua/bugabinga/lsp/clients/zig.lua

Deleted
deleted file mode 100644
1 -local project = require 'std.project'
3 -return {
4 - name = 'zls',
5 - command = 'zls',
6 - filetypes = { 'zig', 'zir' },
7 - root_dir = project.find_zig_project_root,
8 - single_file_support = true,
9 - workspaces = true,
10 -}

neovim/lua/bugabinga/lsp/init.lua

Deleted
deleted file mode 100644
1 -local puk = require 'std.puk'
2 -local project = require 'std.project'
3 -local dbg = require 'std.dbg'
4 -local icon = require 'std.icon'
5 -local map = require 'std.map'
6 -local auto = require 'std.auto'
7 -local table = require 'std.table'
8 -local localrc = require 'std.localrc'
10 -if dbg.get() then
11 - vim.lsp.set_log_level('debug')
12 -end
14 -local language_servers = {
15 - lua_ls = {
16 - root_dir = project.find_lua_project_root,
17 - settings = {
18 - Lua = {
19 - hint = { enable = true, setType = true, },
20 - telemetry = { enable = false, },
21 - },
22 - },
23 - },
24 - -- TODO: take some config from clients/ int here
25 - jdtls = { root_dir = project.find_java_project_root, },
26 - zls = { root_dir = project.find_zig_project_root, },
27 - ziggy = { root_dir = project.find_zig_project_root, },
28 - ziggy_schema = { root_dir = project.find_zig_project_root, },
29 - harper_ls = {},
30 - asm_lsp = {
31 - linters = {
32 - spell_check = true,
33 - spelled_numbers = true,
34 - an_a = true,
35 - sentence_capitalization = true,
36 - unclosed_quotes = true,
37 - wrong_quotes = true,
38 - long_sentences = true,
39 - repeated_words = true,
40 - spaces = true,
41 - matcher = true,
42 - correct_number_suffix = true,
43 - number_suffix_capitalization = true,
44 - multiple_sequential_pronouns = true,
45 - linking_verbs = true,
46 - avoid_curses = true,
47 - terminating_conjunctions = true
48 - },
49 - codeActions = {
50 - forceStable = true
51 - },
52 - root_dir = project.find_vcs_project_root,
53 - },
54 - clangd = {},
55 - denols = {},
56 - dotls = {},
57 - docker_compose_language_service = {},
58 - dockerls = {},
59 - ast_grep = {},
60 - cssls = {},
61 - css_variables = {},
62 - emmet_language_server = {},
63 - gopls = {},
64 - gradle_ls = {},
65 - html = {},
66 - htmx = {},
67 - hyprls = {},
68 - jsonls = {},
69 - lemminx = {},
70 - ltex = {},
71 - marksman = {},
72 - markdown_oxide = {},
73 - nil_ls = {},
74 - nixd = {},
75 - nushell = {},
76 - ocamllsp = {},
77 - protols = {},
78 - roc_ls = {},
79 - rust_analyzer = {},
80 - statix = {},
81 - superhtml = {},
82 - taplo = {},
83 - ts_ls = {},
84 - zk = {},
87 -local lspconfig = puk 'lspconfig'
88 -for server, config in pairs(language_servers) do
89 - local capabilities = vim.lsp.protocol.make_client_capabilities()
90 - config.capabilities = require('bugabinga.completion').get_lsp_capabilities(config.capabilities)
91 - capabilities = table.extend('force', capabilities, config.capabilities)
92 - local settings = config.settings or {}
93 - -- TODO reimplement local settings overrides
94 - -- local settings_override = local_settings(server) or {}
95 - -- config.settings = table.extend('force', settings, settings_override)
96 - lspconfig[server].setup(config)
97 -end
99 -local lsp_attach = function(args)
100 - local bufnr = args.buf
101 - local client_id = args.data.client_id
102 - local client = vim.lsp.get_client_by_id(client_id)
103 - if not client then return end
105 - vim.lsp.completion.enable(true, client_id, bufnr)
107 - if client.server_capabilities.inlayHintProvider then
108 - map.normal {
109 - description = 'Toggle inlay hints',
110 - category = 'lsp',
111 - buffer = bufnr,
112 - keys = '<leader>ti',
113 - command = function()
114 - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
115 - end,
116 - }
117 - end
118 -end
120 -auto 'lsp' {
121 - description = 'lsp: client attached to buffer',
122 - events = 'LspAttach',
123 - command = lsp_attach,
126 -local completion_icons = {
127 - Class = icon.class,
128 - Color = icon.color,
129 - Constant = icon.constant,
130 - Constructor = icon.constructor,
131 - Enum = icon.enum,
132 - EnumMember = icon.enum_member,
133 - Field = icon.field,
134 - File = icon.file,
135 - Folder = icon.folder,
136 - Function = icon['function'],
137 - Interface = icon.interface,
138 - Keyword = icon.keyword,
139 - Method = icon.method,
140 - Module = icon.module,
141 - Property = icon.property,
142 - Snippet = icon.snippet,
143 - Struct = icon.struct,
144 - Text = icon.text,
145 - Unit = icon.unit,
146 - Value = icon.value,
147 - Variable = icon.variable,
150 -local completion_kinds = vim.lsp.protocol.CompletionItemKind
151 -for i, kind in ipairs(completion_kinds) do
152 - completion_kinds[i] = completion_icons[kind] or kind
153 -end

neovim/lua/bugabinga/options/behaviour.lua

Modified
6 6 description = 'briefly highlight yanked text',
7 7 events = 'TextYankPost',
8 8 pattern = '*',
9 - command = function ()
10 - vim.highlight.on_yank {
9 + command = function()
10 + vim.hl.on_yank {
11 11 higroup = 'TextYankPost',
12 12 timeout = 169,
18 18 description = 'Hide columns in buffers, that do not show source code.',
19 19 events = { 'FileType' },
20 20 pattern = ignored.filetypes,
21 - command = function ( data )
21 + command = function(data)
22 22 vim.opt_local.colorcolumn = {}
23 23 vim.opt_local.signcolumn = 'no'
24 24 vim.opt_local.foldcolumn = '0'
30 30 description = 'Reloads the current theme, when USR1 signal is received',
31 31 events = { 'Signal' },
32 32 pattern = 'SIGUSR1',
33 - command = function ()
33 + command = function()
34 34 dbg.print 'received signal USR1! Attempting to reload colorscheme.'
35 35 vim.cmd.colorscheme 'nugu'
36 36 end,
39 39 -- Stolen from mini.misc plugin at https://github.com/echasnovski/mini.misc
41 -local restore_cursor = function ()
41 +local restore_cursor = function()
42 42 -- Stop if not a normal buffer
43 43 if vim.bo.buftype ~= '' then return end
45 45 -- Stop if filetype is ignored
46 - if vim.tbl_contains( ignored.filetypes, vim.bo.filetype ) then return end
46 + if vim.tbl_contains(ignored.filetypes, vim.bo.filetype) then return end
48 48 -- Stop if line is already specified (like during start with `nvim file +num`)
49 - local cursor_line = vim.api.nvim_win_get_cursor( 0 )[1]
49 + local cursor_line = vim.api.nvim_win_get_cursor(0)[1]
50 50 if cursor_line > 1 then return end
52 52 -- Stop if can't restore proper line for some reason
53 - local mark_line = vim.api.nvim_buf_get_mark( 0, [["]] )[1]
54 - local n_lines = vim.api.nvim_buf_line_count( 0 )
53 + local mark_line = vim.api.nvim_buf_get_mark(0, [["]])[1]
54 + local n_lines = vim.api.nvim_buf_line_count(0)
55 55 if not (1 <= mark_line and mark_line <= n_lines) then return end
57 57 -- Restore cursor and open just enough folds
65 65 auto 'restore_cursor_position_setup' {
66 66 description = 'Setup function to restore cursor position',
67 67 events = 'BufReadPre',
68 - command = function ( data )
68 + command = function(data)
69 69 auto 'restore_cursor_position' {
70 70 description = 'Restores last known cursor position when opening a buffer.',
71 71 events = 'FileType',

neovim/lua/bugabinga/options/commands.lua

Modified
1 1 local user_command = require 'std.user_command'
2 2 local light_up = require 'std.light_up'
4 -local light_up_current_buffer = function ()
4 +local light_up_current_buffer = function()
5 5 local group_names = light_up.get_vim_highlight_groups()
6 - light_up.buffer( 0, group_names )
6 + light_up.buffer(0, group_names)
9 -user_command.LightUp
10 -'Highlight hl-group names in current buffer' (
11 - light_up_current_buffer
12 - )
9 +user_command.LightUp 'Highlight hl-group names in current buffer' (light_up_current_buffer)

neovim/lua/bugabinga/options/keymaps.lua

Modified
31 31 command = '<nop>',
34 -local function open_link_under_cursor()
35 - ---@diagnostic disable-next-line: missing-parameter
36 - local file_under_cursor = vim.fn.expand '<cfile>'
37 - --check that it vaguely resembles an URI
38 - ---@diagnostic disable-next-line: param-type-mismatch
39 - if file_under_cursor and file_under_cursor:match '%a+://.+' then
40 - vim.system(
41 - ---@diagnostic disable-next-line: assign-type-mismatch
42 - (const.win32 or const.wsl) and { 'cmd.exe', '/C', 'start', 'msedge', file_under_cursor }
43 - or { 'firefox', file_under_cursor },
44 - { text = true },
45 - function ( completed )
46 - if completed.code == 0 then
47 - vim.schedule( function ()
48 - vim.notify( 'Opened ' .. file_under_cursor )
49 - end )
50 - else
51 - error( 'Failed to open ' .. file_under_cursor .. ' because: ' .. completed.stderr )
52 - end
53 - end
54 - )
55 - else
56 - vim.notify 'Found no url under cursor !'
57 - end
58 -end
60 -map.normal {
61 - description = 'Open web link under cursor in browser',
62 - category = 'navigation',
63 - keys = 'gx',
64 - command = open_link_under_cursor,
67 34 map.normal {
68 35 description = 'Dismiss current search highlight',
69 36 category = 'search',
70 37 keys = '<esc><esc>',
71 - command = function ()
72 - vim.cmd [[ nohlsearch ]]
38 + command = vim.cmd.nohlsearch
41 +map.normal {
42 + description = 'Source current file',
43 + category = 'vim',
44 + keys = '<leader>xx',
45 + command = function()
46 + vim.cmd.source '%'
47 + vim.notify('Sourcing current file...')
77 52 description = 'Toggle dark/light theme variant',
78 53 category = 'ui',
79 54 keys = '<leader>tt',
80 - command = function ()
81 - ---@diagnostic disable-next-line: undefined-field
55 + command = function()
82 56 if vim.opt.background:get() == 'dark' then
83 57 vim.opt.background = 'light'
85 59 vim.opt.background = 'dark'
87 - ---@diagnostic disable-next-line: undefined-field
88 - vim.notify( 'Toggled background to ' .. vim.opt.background:get() .. '.' )
61 + vim.notify('Toggled background to ' .. vim.opt.background:get() .. '.')
96 69 command = vim.cmd.redo,
99 -for _, toggler in ipairs( togglers ) do
72 +for _, toggler in ipairs(togglers) do
100 73 local option_name = toggler.options[1].name
101 - local first_char = string.sub( option_name, 1, 1 )
74 + local first_char = string.sub(option_name, 1, 1)
103 76 map.normal {
104 77 description = 'Toggle ' .. option_name .. ' option',
105 78 category = 'options',
106 79 keys = '<leader>t' .. first_char,
107 - command = function ()
80 + command = function()
108 81 toggler:toggle()

neovim/lua/bugabinga/patterns.lua

Added
new file mode 100644
1 +local puk = require 'std.puk'
3 +puk.defer 'mini.hipatterns' (function(patterns)
4 + patterns.setup {
5 + highlighters = {
6 + -- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE'
7 + fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' },
8 + hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' },
9 + todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' },
10 + note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' },
12 + -- Highlight hex color strings (`#rrggbb`) using that color
13 + hex_color = patterns.gen_highlighter.hex_color(),
14 + },
15 + -- Delays (in ms) defining asynchronous highlighting process
16 + delay = {
17 + -- How much to wait for update after every text change
18 + text_change = 690,
20 + -- How much to wait for update after window scroll
21 + scroll = 420,
22 + },
23 + }
24 +end)

neovim/lua/bugabinga/terminal.lua

Added
new file mode 100644
1 +local puk = require 'std.puk'
2 +local map = require 'std.map'
4 +puk.defer 'neoterm' (function(neoterm)
5 + neoterm.setup {
6 + clear_on_run = true, -- Run clear command before user specified commands
7 + position = 'center', -- Position of the terminal window: fullscreen (0), top (1), right (2), bottom (3), left (4), center (5) (string or integer value)
8 + noinsert = false, -- Disable entering insert mode when opening the neoterm window
9 + width = 0.69, -- Width of the terminal window (percentage, ratio, or range between 0-1)
10 + height = 0.69, -- Height of the terminal window (percentage, ratio, or range between 0-1)
11 + }
13 + map.normal.terminal {
14 + description = 'Toggle terminal',
15 + category = 'terminal',
16 + keys = '<leader>tt',
17 + command = neoterm.toggle,
18 + }
19 +end)

neovim/lua/bugabinga/treesitter.lua

Modified
19 19 command = function(data)
20 20 local match = data.match
21 21 if table.contains(ignored.filetypes, match) then
22 - vim.notify('Ingore ' .. match .. ' for treesitter.')
22 + vim.notify('Ignore ' .. match .. ' for treesitter.', vim.log.levels.TRACE)
23 23 return
25 25 -- try highlights

neovim/lua/std/ignored.lua

Modified
1 --- TODO: add functions to add stuff to lists so that plugins can register these
2 --- and they get cleaned up when plugins get removed
3 1 local filetypes = {
4 2 'Outline',
5 3 'WhichKey',
6 4 '^git.*',
7 5 'bigfile',
6 + 'checkhealth',
8 7 'help',
9 8 'ivy',
10 9 'lazy',

neovim/puk.plugins.nuon

Modified
127 127 "3e92f6764e770ba392325cad3a4497adcada695f",
131 + "mini.hipatterns",
132 + github,
133 + "echasnovski/mini.hipatterns",
134 + main,
135 + "f34975103a38b3f608219a1324cdfc58ea660b8b",
136 + null
137 + ],
131 139 "mini.clue",
132 140 github,
303 311 "1518752906ba3fac0060d9efab6e4d3ec15d4b5a",