repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim: more lsp fun

3d9dbaf049eb9e17acb8c80e1cf7e775069537fe

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (40)

+1412 / −814 text lines · all files grouped into 32 bars

Diff layout

neovim/.luarc.jsonc

Added
new file mode 100644

+21 / −0 text lines

1{
2 "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
3 "runtime": {
4 "version": "LuaJIT"
5 },
6 "diagnostics": {
7 "globals": {
8 "vim"
9 }
10 },
11 "workspace": {
12 "checkThirdParty": false,
13 },
14 "runtime": {
15 "version": "LuaJIT",
16 "pathStrict": true,
17 "special": {
18 "want": "require",
19 }
20 }
21}

neovim/init.lua

Modified

+2 / −1 text lines

1414-- configures the vim diagnostic subsystem
1515require'bugabinga.diagnostic'
1616require'bugabinga.trim'
17require'bugabinga.mark'
1718require'bugabinga.lsp'
1920-- TODO:
21-- [ ] highlight return keyword
2022-- [ ] use ltex-ls for markdown, code comments and commit messages
2123-- [ ] DAP
2224-- [ ] add nu-check to nvim-lint
23-- [ ] Semantic Highlighting: https://gist.github.com/swarn/fb37d9eefe1bc616c2a7e476c0bc0316

neovim/lazy-lock.json

Modified

+24 / −15 text lines

11{
22 "Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" },
3 "LuaSnip": { "branch": "master", "commit": "0b4950a237ce441a6a3a947d501622453f6860ea" },
34 "better-escape.nvim": { "branch": "master", "commit": "7031dc734add47bb71c010e0551829fa5799375f" },
4 "cmp-omni": { "branch": "main", "commit": "9436e6cdd7c5dfa24a99a60d9280b24dbdea3649" },
5 "diffview.nvim": { "branch": "main", "commit": "7e5a85c186027cab1e825d018f07c350177077fc" },
5 "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
6 "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
7 "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
8 "cmp-omni": { "branch": "main", "commit": "4ef610bbd85a5ee4e97e09450c0daecbdc60de86" },
9 "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
10 "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
11 "diffview.nvim": { "branch": "main", "commit": "a111d19ccceac6530448d329c63f998f77b5626e" },
612 "dressing.nvim": { "branch": "master", "commit": "59fe7ef1aeeed499b983614fcfff89206bf0d5ce" },
713 "flash.nvim": { "branch": "main", "commit": "e5a7bd96d0bb7e0806bfc18adea5ab148165bd62" },
14 "friendly-snippets": { "branch": "main", "commit": "ebf6d6e83494cdd88a54a429340256f4dbb6a052" },
815 "gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" },
916 "glow.nvim": { "branch": "main", "commit": "cf2177a514859fa3c55837b46de91d93b24cf488" },
1017 "heirline.nvim": { "branch": "master", "commit": "7f1e805dfc001d5dbb7d894105063f463f6c7dcc" },
11 "hlargs.nvim": { "branch": "main", "commit": "cfc9beab4e176a13311efe03e38e6b6fed5df4f6" },
12 "hydra.nvim": { "branch": "master", "commit": "ceb1fb7e3b4916676674e8a4253deea5a19ab01f" },
18 "hlargs.nvim": { "branch": "main", "commit": "6218a401824c5733ac50b264991b62d064e85ab2" },
19 "hydra.nvim": { "branch": "master", "commit": "3ced42c0b6a6c85583ff0f221635a7f4c1ab0dd0" },
1320 "inc-rename.nvim": { "branch": "main", "commit": "ed0f6f2b917cac4eb3259f907da0a481b27a3b7e" },
1421 "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" },
1522 "lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" },
16 "lush.nvim": { "branch": "main", "commit": "a8f0f7b9f837887f13a61d67b40ae26188fe4d62" },
23 "lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" },
24 "lush.nvim": { "branch": "main", "commit": "966aad1accd47fa11fbe2539234f81f678fef2de" },
1725 "mason.nvim": { "branch": "main", "commit": "d66c60e17dd6fd8165194b1d14d21f7eb2c1697a" },
18 "multicursors.nvim": { "branch": "main", "commit": "65dd5e4eb007cf5796e663ecfa2a2a27cba9d1b7" },
26 "multicursors.nvim": { "branch": "main", "commit": "b7a837496da6f5b39b610a7cbd6c3f7d05526d6e" },
1927 "neodev.nvim": { "branch": "main", "commit": "da1562e1e3df0e994ddc52cb4ba22376a5d7f2fc" },
2028 "neogen": { "branch": "main", "commit": "cb1f384df804c1bf729332c4f728253fe17962d4" },
21 "noice.nvim": { "branch": "main", "commit": "791c7adda821fd03529f995df2ee284ad591dabd" },
29 "noice.nvim": { "branch": "main", "commit": "396f9146529130904e07c45e90ecdbfa607534f3" },
2230 "nrpattern.nvim": { "branch": "master", "commit": "f862ce687761078ef3155688151c55f69d28453e" },
2331 "nui.nvim": { "branch": "main", "commit": "9e3916e784660f55f47daa6f26053ad044db5d6a" },
24 "nvim-autopairs": { "branch": "master", "commit": "defad64afbf19381fe31488a7582bbac421d6e38" },
32 "nvim-autopairs": { "branch": "master", "commit": "de4f7138a68d5d5063170f2182fd27faf06b0b54" },
2533 "nvim-cmp": { "branch": "main", "commit": "983453e32cb35533a119725883c04436d16c0120" },
2634 "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" },
27 "nvim-genghis": { "branch": "main", "commit": "c3f043860f02370bfe9bba24f0c93658d01dd6ea" },
35 "nvim-genghis": { "branch": "main", "commit": "b15d7d0c37f7739a5723f20dfae9e501b9952b08" },
2836 "nvim-gomove": { "branch": "main", "commit": "2b44ae7ac0804f4e3959228122f7c85bef1964e3" },
2937 "nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" },
3038 "nvim-neoclip.lua": { "branch": "main", "commit": "4e406ae0f759262518731538f2585abb9d269bac" },
3139 "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" },
3240 "nvim-surround": { "branch": "main", "commit": "0d6882635817a2677749a330127d12ac30a4f3c8" },
33 "nvim-treesitter": { "branch": "master", "commit": "48b237fd3f482aef2f5896b8b7a6ece71c19ad99" },
41 "nvim-treesitter": { "branch": "master", "commit": "f3fb301b267e85e4cbc725561da4a82b1c3089c8" },
42 "nvim-treesitter-textobjects": { "branch": "master", "commit": "bd103502252027434ec42f628d2dbf54821d4ce6" },
3443 "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },
3544 "nvim-ts-context-commentstring": { "branch": "main", "commit": "95e9ba9de4289d221666b66fd930d157c7ca08c6" },
36 "nvim-web-devicons": { "branch": "master", "commit": "973ab742f143a796a779af4d786ec409116a0d87" },
45 "nvim-web-devicons": { "branch": "master", "commit": "45d0237c427baba8cd05e0ab26d30e2ee58c2c82" },
3746 "oil.nvim": { "branch": "master", "commit": "fdb50dc5c57524c4b0b05b593abff4d4f7a099f6" },
3847 "persistence.nvim": { "branch": "main", "commit": "adcf6913693a0434665d162ee45a186230496f8a" },
39 "playground": { "branch": "master", "commit": "429f3e76cbb1c59fe000b690f7a5bea617b890c0" },
48 "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
4049 "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" },
41 "refactoring.nvim": { "branch": "master", "commit": "2ec9bc0fb5f3c8c6a0f776f0159dd2a3b1663554" },
4250 "schemastore.nvim": { "branch": "main", "commit": "ce624332e6ba5a9a0c8f311a114ac179c5e72f62" },
4351 "specs.nvim": { "branch": "main", "commit": "2743e412bbe21c9d73954c403d01e8de7377890d" },
4452 "substitute.nvim": { "branch": "main", "commit": "42d09f1e6324d98aa2e5b765b64528e0aefe72b0" },
4755 "telescope-zoxide": { "branch": "main", "commit": "68966349aa1b8e9ade403e18479ecf79447389a7" },
4856 "telescope.nvim": { "branch": "0.1.x", "commit": "54930e1abfc94409e1bb9266e752ef8379008592" },
4957 "todo-comments.nvim": { "branch": "main", "commit": "8febc60a76feefd8203077ef78b6a262ea1a41f9" },
50 "toggleterm.nvim": { "branch": "main", "commit": "b90a1381e9b5b8596f49070ee86c71db267ac868" },
58 "toggleterm.nvim": { "branch": "main", "commit": "faee9d60428afc7857e0927fdc18daa6c409fa64" },
5159 "treesj": { "branch": "main", "commit": "bff8c32b826e188fa558e94c7c93ac17a8ef0365" },
5260 "twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" },
53 "virt-column.nvim": { "branch": "master", "commit": "1917bfb519729dea7b4f5d13aa9c810c9579b0ea" },
61 "virt-column.nvim": { "branch": "master", "commit": "5fc72873dc3175eddbdbbedea8071919c99ad755" },
62 "which-key.nvim": { "branch": "main", "commit": "bf09a25bdc9a83bcc69d2cf078e680368676513b" },
5463 "zen-mode.nvim": { "branch": "main", "commit": "6e6c963d70a8e47854fa656987666bfb863f9c4e" }
5564}No final newline

neovim/lua/bugabinga/diagnostic.lua

Modified

+50 / −49 text lines

11local want = require 'std.want'
2local map = require 'std.keymap'
3local auto = require'std.auto'
4local icon = require'std.icon'
2local map = require 'std.map'
3local auto = require 'std.auto'
4local icon = require 'std.icon'
66local icon = { icon.error, icon.warn, icon.info, icon.hint }
77icon.error = icon[1]
1010icon.hint = icon[4]
1212local display_name = {
13 'Error',
14 'Warning',
15 'Information',
16 'Hint',
13 'Error',
14 'Warning',
15 'Information',
16 'Hint',
1919local diagnostic = vim.diagnostic
20diagnostic.disable(0)
20diagnostic.disable( 0 )
22auto 'disable_diagnostic_initially'{
22auto 'disable_diagnostic_initially' {
2323 description = 'Disable Diagnostics initially, when attaching an LSP client to a buffer',
2424 events = 'LspAttach',
25 command = function() diagnostic.disable(0) end,
25 command = function () diagnostic.disable( 0 ) end,
28local diagnostic_format = function(context)
29 return string.format('%s: %s', display_name[context.severity], context.message)
28local diagnostic_format = function ( context )
29 return string.format( '%s: %s', display_name[context.severity], context.message )
3030end
32local prefix_format = function(context, index, total)
33 return string.format('%s/%s %s %s ', index, total, context.source, icon[context.severity]), 'DiagnosticVirtualText'.. display_name[context.severity]
32local prefix_format = function ( context, index, total )
33 return string.format( '%s/%s %s %s ', index, total, context.source, icon[context.severity] ),
34 'DiagnosticVirtualText' .. display_name[context.severity]
3435end
3637diagnostic.config {
3738 underline = true,
3839 virtual_text = {
39 severity = { min = diagnostic.severity.WARN },
40 severity = { min = diagnostic.severity.WARN },
4041 source = false,
4142 spacing = 2,
4243 prefix = '⦿ ',
5556 severity_sort = true,
58local sign = function(options)
59 vim.fn.sign_define(options.name, {
59local sign = function ( options )
60 vim.fn.sign_define( options.name, {
6061 text = options.text,
6162 texthl = options.name,
6263 numhl = nil,
6364 culhl = nil,
6465 linehl = nil,
65 })
66 } )
6667end
6869sign { name = 'DiagnosticSignError', text = icon.error }
7172sign { name = 'DiagnosticSignInfo', text = icon.info }
7374map.normal {
74 name = 'Toggle diagnostics',
75 description = 'Toggle diagnostics',
7576 category = 'diagnostic',
7677 keys = '<F6><F6>',
77 command = function()
78 if diagnostic.is_disabled(0) then
79 diagnostic.enable(0)
78 command = function ()
79 if diagnostic.is_disabled( 0 ) then
80 diagnostic.enable( 0 )
8081 vim.notify 'Enabling Diagnostics'
8182 else
82 diagnostic.disable(0)
83 diagnostic.disable( 0 )
8384 vim.notify 'Disabling Diagnostics'
8485 end
8586 end,
8889map.normal {
89 name = 'Show diagnostics under cursor',
90 description = 'Show diagnostics under cursor',
9091 category = 'diagnostic',
9192 keys = 'H',
9293 command = diagnostic.open_float,
95local show_diagnostics_in_buffer = function()
96 want{ 'telescope.builtin', 'telescope.themes' }(
97 function(builtin, themes)
98 builtin.diagnostics(themes.get_dropdown{ bufnr=0 })
99 end)
96local show_diagnostics_in_buffer = function ()
97 want { 'telescope.builtin', 'telescope.themes' } (
98 function ( builtin, themes )
99 builtin.diagnostics( themes.get_dropdown { bufnr = 0, layout_config = { width = 0.69 } } )
100 end )
100101end
102103map.normal {
103 name = 'Show all diagnostics in buffer',
104 description = 'Show all diagnostics in buffer',
104105 category = 'diagnostic',
105106 keys = '<F6>',
106107 command = show_diagnostics_in_buffer,
109local show_diagnostics_in_workspace = function()
110 want{ 'telescope.builtin', 'telescope.themes' }(
111 function(builtin, themes)
112 builtin.diagnostics(themes.get_dropdown{})
113 end)
110local show_diagnostics_in_workspace = function ()
111 want { 'telescope.builtin', 'telescope.themes' } (
112 function ( builtin, themes )
113 builtin.diagnostics( themes.get_dropdown { layout_config = { width = 0.69 } } )
114 end )
114115end
116117map.normal {
117 name = 'Show all diagnostics in workspace',
118 description = 'Show all diagnostics in workspace',
118119 category = 'diagnostic',
119120 keys = '<leader><F6>',
120121 command = show_diagnostics_in_workspace,
123124map.normal {
124 name = 'Go to previous diagnostic',
125 description = 'Go to previous diagnostic',
125126 category = 'diagnostic',
126127 keys = '<C-.>',
127128 command = diagnostic.goto_prev,
130131map.normal {
131 name = 'Go to next diagnostic',
132 description = 'Go to next diagnostic',
132133 category = 'diagnostic',
133134 keys = '<C-,>',
134135 command = diagnostic.goto_next,
137138-- a little debug helper to show all kinds of diagnostics
139local dia = function( severity, line )
140 local ns = vim.api.nvim_create_namespace('test'.. tostring(severity))
140local dia = function ( severity, line )
141 local ns = vim.api.nvim_create_namespace( 'test' .. tostring( severity ) )
141142 local bufnr = vim.api.nvim_get_current_buf()
142143 local options = {
143144 bufnr = bufnr,
145146 end_lnum = line,
146147 col = 0,
147148 severity = severity,
148 message = 'This is a test ' .. tostring(severity) .. ' diagnostic',
149 message = 'This is a test ' .. tostring( severity ) .. ' diagnostic',
149150 }
151 vim.diagnostic.set(ns, bufnr, {options})
152 vim.diagnostic.show(ns, bufnr, {options})
152 vim.diagnostic.set( ns, bufnr, { options } )
153 vim.diagnostic.show( ns, bufnr, { options } )
153154end
155local send_dia = function()
156 dia(vim.diagnostic.severity.ERROR, 1)
157 dia(vim.diagnostic.severity.WARN, 2)
158 dia(vim.diagnostic.severity.INFO, 3)
159 dia(vim.diagnostic.severity.HINT, 4)
156local send_dia = function ()
157 dia( vim.diagnostic.severity.ERROR, 1 )
158 dia( vim.diagnostic.severity.WARN, 2 )
159 dia( vim.diagnostic.severity.INFO, 3 )
160 dia( vim.diagnostic.severity.HINT, 4 )
160161end
162vim.g.send_dia = send_dia
163vim.g.send_dia = send_diaNo final newline

neovim/lua/bugabinga/lazy.lua

Modified

+4 / −4 text lines

2525 version = '*',
2626 },
2727 install = {
28 missing = true,
28 missing = false,
2929 colorscheme = { 'nugu', 'quiet' },
3030 },
3131 checker = {
4242 },
4343 },
4444 custom_keys = false,
45 concurrency = 8,
45 change_detection = { notify = false },
4646 performance = {
4747 rtp = {
4848 disabled_plugins = {
7777 },
7878})
80local map = require 'std.keymap'
80local map = require 'std.map'
8282local lazy_cmds = vim.iter {
8383 { 'Show', '' , lazy.show } ,
101101 keys = base_key .. cmd[2],
102102 command = cmd[3],
103103 }
104end)
104end)No final newline

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

Modified

+2 / −2 text lines

11local project = require'std.project'
33return {
4 name = 'clangd',
4 description = 'clangd',
55 command = 'clangd',
66 filetypes = 'c',
77 root_dir = project.find_vcs_project_root,
1515 },
1616 offsetEncoding = { 'utf-8', 'utf-16' },
1717 },
18}
18}No final newline

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

Modified

+2 / −10 text lines

1local lua = require'bugabinga.lsp.clients.lua'
2local java = require'bugabinga.lsp.clients.java'
3
4-- FIXME: it is not possible right now to start multiple LSPs perf buffer
5-- NOTE: The order of clients is implicitly priorization.
6-- Put "more specific" clients first
71return {
8 lua.nvim_lua_ls,
9 lua.lua_ls,
10 java.jdtls,
11 java.jdtls_ss,
2 require'bugabinga.lsp.clients.java',
3 require'bugabinga.lsp.clients.lua',
124 require'bugabinga.lsp.clients.json',
135 require'bugabinga.lsp.clients.archlinux',
146 require'bugabinga.lsp.clients.asm',

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

Modified

+22 / −37 text lines

1local table = require'std.table'
2local project = require'std.project'
1local table = require 'std.table'
2local project = require 'std.project'
44local create_shared_config_path = function(base_path, syntax_server)
55 local os_config
1818 local launchers = vim.fn.globpath(plugins_dir, 'org.eclipse.equinox.launcher_*.jar', false, true)
2020 if table.is_empty(launchers) then
21 vim.error('Could not find jdtls launcher jar in ' .. plugins_dir )
21 vim.error('Could not find jdtls launcher jar in ' .. plugins_dir)
2222 end
2424 -- vim.print('found launcher jars', launchers)
2626end
2828local create_data_dir = function()
29 local data_name = vim.fn.sha256(vim.uv.cwd())
30 local cache = vim.fn.stdpath'cache'
29 local cwd = vim.uv.cwd() or ''
30 local data_name = vim.fn.sha256(cwd)
31 local cache = vim.fn.stdpath 'cache'
32 cache = type(cache) == 'table' and cache[1] or cache
3234 return vim.fs.joinpath(cache, 'jdtls_data', data_name)
3335end
3537local create_jdtls_command = function(syntax_server)
36 local mason_packages_base_path = require'mason-core.package':get_install_path()
38 local mason_packages_base_path = require 'mason-core.package':get_install_path()
3739 local jdtls_package_path = vim.fs.joinpath(mason_packages_base_path, 'jdtls')
3840 local shared_config_path = create_shared_config_path(jdtls_package_path, syntax_server)
3941 local launcher_jar = find_launcher_jar(jdtls_package_path)
4749 '-Dosgi.bundles.defaultStartLevel=4',
4850 '-Declipse.product=org.eclipse.jdt.ls.core.product',
4951 '-Dlog.protocol=true',
50 '-Dlog.level=INFO',
52 '-Dlog.level=ALL',
5153 "-Dosgi.checkConfiguration=true",
52 "-Dosgi.sharedConfiguration.area=" .. shared_config_path,
54 "-Dosgi.sharedConfiguration.area=" .. shared_config_path,
5355 "-Dosgi.sharedConfiguration.area.readOnly=true",
5456 "-Dosgi.configuration.cascaded=true",
5557 ss_option,
56 "-Xms1g",
57 '-Xmx4g',
5858 '--add-modules=ALL-SYSTEM',
5959 '--add-opens', 'java.base/java.util=ALL-UNNAMED',
6060 '--add-opens', 'java.base/java.lang=ALL-UNNAMED',
8080 jdk17.path = '/usr/lib/jvm/openjdk-17'
8181 jdk19.path = '/usr/lib/jvm/openjdk-19'
8282 else
83 vim.notify'missing jdk paths in java settings for lsp'
83 vim.notify 'missing jdk paths in java settings for lsp'
8484 end
86 return {jdk11, jdk17, jdk20 }
86 return { jdk11, jdk17, jdk19 }
8787end
8989local java_settings = {
9494 staticStarThreshold = 9999,
9595 },
9696 },
97 configuration = { runtimes = find_jdks(), };
97 configuration = { runtimes = find_jdks(), },
100100local jdtls_lsp_start = function(config, opts)
101101 -- vim.print('jdtls lsp start', config, opts)
102 require'jdtls'.start_or_attach(config,opts)
102 require 'jdtls'.start_or_attach(config, opts)
103103end
105105return {
106 jdtls = {
107 custom_start = jdtls_lsp_start,
108 name = 'jdtls',
109 filetypes = 'java',
110 command = create_jdtls_command(),
111 root_dir = project.find_java_project_root,
112 single_file_support = false,
113 workspaces = true,
114 settings = { java = java_settings },
115 init_options = {
116 bundles = {}
117 },
118 },
119 jdtls_ss = {
120 custom_start = jdtls_lsp_start,
121 name = 'jdtls_ss',
122 filetypes = 'java',
123 command = create_jdtls_command(true),
124 root_dir = project.find_java_project_root,
125 single_file_support = true,
126 workspaces = false,
127 settings = { java = java_settings },
128 },
106 custom_start = jdtls_lsp_start,
107 name = 'jdtls',
108 filetypes = 'java',
109 command = create_jdtls_command(true),
110 root_dir = project.find_java_project_root,
111 single_file_support = true,
112 workspaces = false,
113 settings = { java = java_settings },

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

Modified

+7 / −43 text lines

1local project = require'std.project'
1local project = require 'std.project'
3local lua_ls =
4{
3return {
54 name = 'LuaLS',
65 filetypes = 'lua',
76 command = 'lua-language-server',
8 root_dir = project.find_lua_project_root,
7 root_dir = function ( path )
8 return project.find_lua_nvim_project_root( path ) or project.find_lua_project_root( path )
9 end,
910 single_file_support = true,
1011 workspaces = true,
11 settings = {
12 Lua = {
13 addonManager = { enable = false },
14 completion = { callSnippet = 'Both', postfix = '.' },
15 diagnostics = { workspaceRate = 50 },
16 hint = { enable = true, setType = true },
17 runtime = {
18 version = "Lua 5.4",
19 pathStrict = true,
20 },
21 telemetry = { enable = true },
22 window = { progressBar = false, statusBar = false },
23 workspace = { checkThirdParty = false, }
24 },
25 }
26}
28local nvim_lua_ls =
29{
30 name = 'LuaLS(nvim)',
31 filetypes = 'lua',
32 command = 'lua-language-server',
33 root_dir = project.find_lua_nvim_project_root,
34 single_file_support = false,
35 workspaces = true,
3612 settings = {
3713 Lua = {
3814 addonManager = { enable = false },
3915 completion = { callSnippet = 'Both', postfix = '.' },
4016 diagnostics = { globals = { 'vim' }, workspaceRate = 50 },
4117 hint = { enable = true, setType = true },
42 runtime = {
43 version = 'LuaJIT',
44 pathStrict = true,
45 special = {
46 want = 'require',
47 },
48 },
49 telemetry = { enable = true },
18 telemetry = { enable = false },
5019 window = { progressBar = false, statusBar = false },
5120 workspace = { checkThirdParty = false, }
5221 },
5322 },
54 before_init = require"neodev.lsp".before_init,
55}
57return {
58 lua_ls = lua_ls,
59 nvim_lua_ls = nvim_lua_ls,
23 before_init = require 'neodev.lsp'.before_init,

neovim/lua/bugabinga/lsp/init.lua

Modified

+182 / −186 text lines

1local defer = require'std.defer'
2local map = require 'std.keymap'
1require 'bugabinga.lsp.lightbulb'
2
3local defer = require 'std.defer'
4local map = require 'std.map'
35local auto = require 'std.auto'
6local want = require 'std.want'
47local ui = require 'bugabinga.ui'
58local table = require 'std.table'
69local ignored = require 'std.ignored'
811local lsp_client_configs = require 'bugabinga.lsp.clients'
912local _ = {}
11local token_update = function ( lsp_client )
12 local token = lsp_client.data.token
13 local buffer = lsp_client.buffer
14 local client_id = lsp_client.data.client_id
15 local mutable_variable_highlight = 'MutableVariable'
14 local token_update = function ( lsp_client )
15 local token = lsp_client.data.token
16 local buffer = lsp_client.buffer
17 local client_id = lsp_client.data.client_id
18 local mutable_variable_highlight = 'MutableVariable'
17 if token.type == 'variable' and not token.modifiers.readonly then
18 vim.lsp.semantic_tokens.highlight_token( token, buffer, client_id, mutable_variable_highlight )
20 if token.type == 'variable' and not token.modifiers.readonly then
21 vim.lsp.semantic_tokens.highlight_token( token, buffer, client_id, mutable_variable_highlight )
22 end
24 --TODO: find more use cases for semantic tokens
25 --* global variables
26 --* functions with side effects
27 --* closures that capture something
1928 end
21 --TODO: find more use cases for semantic tokens
22 --* global variables
23 --* functions with side effects
24 --* closures that capture something
25end
27local expand_path = function ( path )
28 if vim.fn.executable( path ) == 1 then
29 return vim.fn.exepath( path )
30 else
31 return path
32 end
33end
35local expand_command = function ( command )
36 vim.validate { command = { command, { 'string', 'table' } } }
38 -- vim.print( 'expanding command', command )
40 if type( command ) == 'table' then
41 command[1] = expand_path( command[1] )
42 return command
30 local expand_path = function ( path )
31 if vim.fn.executable( path ) == 1 then
32 return vim.fn.exepath( path )
33 else
34 return path
35 end
4336 end
45 return expand_path( command )
46end
38 local expand_command = function ( command )
39 vim.validate { command = { command, { 'string', 'table' } } }
48local lsp_start = function ( file_type_event )
49 -- vim.print("LSP START", file_type_event)
41 -- vim.print( 'expanding command', command )
51 local match = file_type_event.match
43 if type( command ) == 'table' then
44 command[1] = expand_path( command[1] )
45 return command
46 end
53 local matches_to_ignore = ignored.filetypes
54 -- vim.print('filetypes to ignore', matches_to_ignore)
55 if vim.iter( matches_to_ignore ):find( match ) then return end
48 return expand_path( command )
49 end
57 local bufnr = file_type_event.buf
58 local buffer_path = vim.api.nvim_buf_get_name( bufnr )
51 local lsp_start = function ( file_type_event )
52 -- vim.print("LSP START", file_type_event)
60 -- vim.print( "SEARCHING LSP CLIENT FOR:", match, buffer_path)
54 local match = file_type_event.match
62 local potential_client_configs = vim.iter( lsp_client_configs )
63 :map( function ( config )
64 vim.validate {
65 ['config'] = { config, 'table' },
66 ['config.name'] = { config.name, 'string' },
67 ['config.filetypes'] = { config.filetypes, { 'string', 'table' } },
68 ['config.command'] = { config.command, { 'string', 'table' } },
69 ['config.environment'] = { config.environment, 'table', true },
70 ['config.root_dir'] = { config.root_dir, 'function', 'string' },
71 ['config.single_file_support'] = { config.single_file_support, 'boolean', true },
72 ['config.settings'] = { config.settings, 'table', true },
73 ['config.workspaces'] = { config.workspaces, 'boolean', true },
74 ['config.before_init'] = { config.before_init, 'function', true },
75 ['config.init_options'] = { config.init_options, 'table', true },
76 ['config.capabilities'] = { config.capabilities, 'table', true },
77 ['config.custom_start'] = { config.custom_start, 'function', true },
56 local matches_to_ignore = ignored.filetypes
57 -- vim.print('filetypes to ignore', matches_to_ignore)
58 if vim.iter( matches_to_ignore ):find( match ) then return end
60 local bufnr = file_type_event.buf
61 local buffer_path = vim.api.nvim_buf_get_name( bufnr )
63 -- vim.print( "SEARCHING LSP CLIENT FOR:", match, buffer_path)
65 local potential_client_configs = vim.iter( lsp_client_configs )
66 :map( function ( config )
67 vim.validate {
68 ['config'] = { config, 'table' },
69 ['config.name'] = { config.name, 'string' },
70 ['config.filetypes'] = { config.filetypes, { 'string', 'table' } },
71 ['config.command'] = { config.command, { 'string', 'table' } },
72 ['config.environment'] = { config.environment, 'table', true },
73 ['config.root_dir'] = { config.root_dir, 'function', 'string' },
74 ['config.single_file_support'] = { config.single_file_support, 'boolean', true },
75 ['config.settings'] = { config.settings, 'table', true },
76 ['config.workspaces'] = { config.workspaces, 'boolean', true },
77 ['config.before_init'] = { config.before_init, 'function', true },
78 ['config.init_options'] = { config.init_options, 'table', true },
79 ['config.capabilities'] = { config.capabilities, 'table', true },
80 ['config.custom_start'] = { config.custom_start, 'function', true },
81 }
82 -- normalize scalar values to its vector alternative for easier processing later on
83 -- this mutates the lsp client configs! careful!
84 config.command = type( config.command ) == 'string' and { expand_command( config.command ) } or
85 expand_command( config.command )
86 config.environment = config.environment or {}
87 config.filetypes = type( config.filetypes ) == 'string' and { config.filetypes } or config.filetypes
88 config.single_file_support = config.single_file_support == nil and false or config.single_file_support
89 config.workspaces = config.workspaces == nil and false or config.workspaces
90 config.capabilities = config.capabilities or {}
91 config.init_options = config.init_options or {}
93 return config
94 end )
95 :filter( function ( config )
96 return vim.iter( config.filetypes ):find( match )
97 end )
98 :totable()
100 -- vim.print("POTENTIAL CLIENTS", vim.iter(potential_client_configs):map(function(config) return { name = config.name, command = config.command } end):totable())
102 if table.is_empty( potential_client_configs ) then
103 -- vim.notify( 'found no lsp client for', buffer_path )
104 return
105 end
107 for _, config in ipairs( potential_client_configs ) do
108 local root_dir = type( config.root_dir ) == 'string' and config.root_dir or config.root_dir( buffer_path )
109 local capabilities = vim.lsp.protocol.make_client_capabilities()
110 local cmp_capabilities = want 'cmp_nvim_lsp' ( function ( cmp )
111 return cmp.default_capabilities()
112 end, {} )
113 capabilities = table.extend( 'force', capabilities, cmp_capabilities, config.capabilities )
114 -- vim.print( 'lsp capabilities', capabilities, config.capabilities, cmp_capabilities )
116 local start_config = {
117 cmd = config.command,
118 cmd_cwd = root_dir,
119 -- cmd_env = config.environment,
120 detached = false, -- do i want this?
121 -- workspace_folders = { config.root_dir(buffer_path) }, -- TODO: i think workspaces can only ever be declared per project. i cannot think of a generic way to calculate those, like with root_dir. maybe a toml/ini file in root_dir sets these?
122 capabilities = capabilities,
123 -- handlers = vim.lsp.handlers,
124 settings = config.settings,
125 -- commands = nil, -- what is this?
126 init_options = config.init_options,
127 name = config.name,
128 -- get_language_id = nil,
129 -- offset_encoding = nil,
130 on_error = function ( code, ... ) vim.print( 'LSP ERROR', code, ... ) end,
131 before_init = config.before_init,
132 -- on_init = nil, -- should i send workspace/didChangeConfiguration here?
133 -- on_exit = function(code, signal, client_id) vim.print("LSP CLIENT EXIT", code, signal, client_id) end,
134 -- on_attach = function(client, bufnr) vim.print("LSP CLIENT ATTACH", client.data.client_id, bufnr) end,
135 trace = 'off',
136 flags = { allow_incremental_sync = true, debounce_text_changes = 250, exit_timeout = 200 },
137 root_dir = root_dir,
78138 }
79 -- normalize scalar values to its vector alternative for easier processing later on
80 -- this mutates the lsp client configs! careful!
81 config.command = type( config.command ) == 'string' and { expand_command( config.command ) } or
82 expand_command( config.command )
83 config.environment = config.environment or {}
84 config.filetypes = type( config.filetypes ) == 'string' and { config.filetypes } or config.filetypes
85 config.single_file_support = config.single_file_support == nil and false or config.single_file_support
86 config.workspaces = config.workspaces == nil and false or config.workspaces
87 config.capabilities = config.capabilities or {}
88 config.init_options = config.init_options or {}
90 return config
91 end )
92 :filter( function ( config )
93 return vim.iter( config.filetypes ):find( match )
94 end )
95 :totable()
140 local lsp_starter = config.custom_start or vim.lsp.start
97 -- vim.print("POTENTIAL CLIENTS", vim.iter(potential_client_configs):map(function(config) return { name = config.name, command = config.command } end):totable())
142 -- vim.print( 'starting lsp', start_config.name, root_dir )
99 -- find clients, that returns some root_dir for this buffer
100 local config = vim.iter( potential_client_configs ):find(
101 function ( _ ) return _.root_dir( buffer_path ) ~= nil end
102 )
144 lsp_starter( start_config, {
145 bufnr = bufnr,
146 -- TODO: reuse if workspaces
147 -- local supported = vim.tbl_get(client, 'server_capabilities', 'workspace', 'workspaceFolders', 'supported')
148 reuse_client = function ( existing_client, new_config )
149 --TODO lsps with single file or worksopaces support do not need smame root dir. instead add_workspace_folder
150 local same_name_and_root = existing_client.name == new_config.name and
151 existing_client.workspace_folders[1] == new_config.root_dir;
152 -- vim.print( 'resuing lsp client?', same_name_and_root )
153 return same_name_and_root;
154 end,
155 } )
104 -- if no client can open this buffer as part of a project (root_dir), then look
105 -- for a client with single file support
106 -- FIXME: root_dir needs to change if single file mode
107 config = config or vim.iter( potential_client_configs ):find(
108 function ( _ ) return _.single_file_support end
109 )
111 if not config then
112 -- vim.print('FOUND NO LSP CLIENT FOR', buffer_path)
113 return
157 -- vim.print("ATTACHING LSP CLIENT", client_id)
158 end
114159 end
116 assert( config, 'a matching LSP client config shoud have been found by now!' )
161 local old_formatexpr
162 local old_omnifunc
163 local old_tagfunc
118 local root_dir = type( config.root_dir ) == 'string' and config.root_dir or config.root_dir( buffer_path )
119 local capabilities = vim.lsp.protocol.make_client_capabilities()
120 capabilities = table.extend( 'force', capabilities, config.capabilities )
165 local lsp_attach = function ( args )
166 local bufnr = args.buf
167 local client = vim.lsp.get_client_by_id( args.data.client_id )
168 if not client then return end
122 local start_config = {
123 cmd = config.command,
124 cmd_cwd = root_dir,
125 -- cmd_env = config.environment,
126 detached = false, -- do i want this?
127 -- workspace_folders = { config.root_dir(buffer_path) }, -- TODO: i think workspaces can only ever be declared per project. i cannot think of a generic way to calculate those, like with root_dir. maybe a toml/ini file in root_dir sets these?
128 capabilities = capabilities,
129 -- handlers = vim.lsp.handlers,
130 settings = config.settings,
131 -- commands = nil, -- what is this?
132 init_options = config.init_options,
133 name = config.name,
134 -- get_language_id = nil,
135 -- offset_encoding = nil,
136 on_error = function ( code, ... ) vim.print( 'LSP ERROR', code, ... ) end,
137 before_init = config.before_init,
138 -- on_init = nil, -- should i send workspace/didChangeConfiguration here?
139 -- on_exit = function(code, signal, client_id) vim.print("LSP CLIENT EXIT", code, signal, client_id) end,
140 -- on_attach = function(client, bufnr) vim.print("LSP CLIENT ATTACH", client.data.client_id, bufnr) end,
141 trace = 'off',
142 flags = { allow_incremental_sync = true, debounce_text_changes = 50, exit_timeout = 200 },
143 root_dir = root_dir,
144 }
170 -- vim.print(client.server_capabilities)
146 local lsp_starter = config.custom_start or vim.lsp.start
172 if client.server_capabilities.definitionProvider then
173 old_tagfunc = vim.bo[bufnr].tagfunc
174 vim.bo[bufnr].tagfunc = 'v:lua.vim.lsp.tagfunc'
175 end
148 local client_id = lsp_starter( start_config, {
149 bufnr = bufnr,
150 -- TODO: reuse if workspaces
151 -- local supported = vim.tbl_get(client, 'server_capabilities', 'workspace', 'workspaceFolders', 'supported')
152 -- reuse_client = function(existing_client, config)end,
153 } )
177 if client.server_capabilities.documentFormattingProvider then
178 old_formatexpr = vim.bo[bufnr].formatexpr
179 vim.bo[bufnr].formatexpr = 'v:lua.vim.lsp.formatexpr(#{timeout_ms:50})'
180 end
155 -- vim.print("ATTACHING LSP CLIENT", client_id)
156end
182 if client.server_capabilities.completionProvider then
183 old_omnifunc = vim.bo[bufnr].omnifunc
184 vim.bo[bufnr].omnifunc = 'v:vim.lsp.omnifunc'
185 end
158local old_formatexpr
159local old_omnifunc
160local old_tagfunc
187 -- if client.server_capabilities.inlayHintProvider then
188 -- TODO: how to prevent the UI from jittering
189 -- vim.lsp.inlay_hint( bufnr, true )
190 -- end
162local lsp_attach = function ( args )
163 local bufnr = args.buf
164 local client = vim.lsp.get_client_by_id( args.data.client_id )
165 if not client then return end
167 -- vim.print(client.server_capabilities)
169 if client.server_capabilities.definitionProvider then
170 old_tagfunc = vim.bo[bufnr].tagfunc
171 vim.bo[bufnr].tagfunc = 'v:lua.vim.lsp.tagfunc'
172 end
174 if client.server_capabilities.documentFormattingProvider then
175 old_formatexpr = vim.bo[bufnr].formatexpr
176 vim.bo[bufnr].formatexpr = 'v:lua.vim.lsp.formatexpr(#{timeout_ms:50})'
177 end
179 if client.server_capabilities.completionProvider then
180 old_omnifunc = vim.bo[bufnr].omnifunc
181 vim.bo[bufnr].omnifunc = 'v:vim.lsp.omnifunc'
182 end
184 -- TODO: create register/unregister abstraction for lsp features
185 -- TODO: show available code actions as diagnostics (must be filtered)
186 -- TODO: use nicer guis for lsp interactive features
187 map.normal {
188 name = 'Show available code actions on current line.',
189 category = 'lsp',
192 -- TODO: create register/unregister abstraction for lsp features
193 -- TODO: show available code actions as diagnostics (must be filtered)
194 -- TODO: use nicer guis for lsp interactive features
195 map.normal {
196 description = 'Show available code actions on current line.',
197 category = 'lsp',
190198 keys = '<c-1>',
191199 command = vim.lsp.buf.code_action,
192200 }
194202 map.normal {
195 name = 'Goto to definition of symbol under cursor.',
203 description = 'Goto to definition of symbol under cursor.',
196204 category = 'lsp',
197205 keys = '<c-2>',
198206 command = vim.lsp.buf.definition,
199207 }
200208 map.normal {
201 name = 'Goto to definition of symbol under cursor.',
209 description = 'Goto to definition of symbol under cursor.',
202210 category = 'telescope',
203211 keys = '<c-2><c-2>',
204212 command = '<cmd>Telescope lsp_definitions<cr>',
207215 if client.server_capabilities.documentHighlightProvider then
208216 -- the timer has application lifetime. no need to close
209217 local delay = 300
210 local debounced_highlight = defer.debounce_trailing(vim.lsp.buf.document_highlight, delay)
211 local debounced_clear = defer.debounce_trailing(vim.lsp.buf.clear_references, delay)
218 local debounced_highlight = defer.debounce_leading( vim.lsp.buf.document_highlight, delay )
219 local debounced_clear = defer.debounce_leading( vim.lsp.buf.clear_references, delay )
213221 auto 'document_highlight' {
214222 {
226234 }
227235 end
229 --TODO: what can we do with those?
230 --maybe: LspCommand <command> <args>
231 -- map to <c-3>
232 if client.server_capabilities.executeCommandProvider then
233 -- [1] ≔ 󰝗 lua.removeSpace 󰉾,
234 -- [2] ≔ 󰝗 lua.solve 󰉾,
235 -- [3] ≔ 󰝗 lua.jsonToLua 󰉾,
236 -- [4] ≔ 󰝗 lua.setConfig 󰉾,
237 -- [5] ≔ 󰝗 lua.getConfig 󰉾,
238 -- [6] ≔ 󰝗 lua.autoRequire 󰉾,
239 end
241237 map.normal {
242 name = 'Format current buffer',
238 description = 'Format current buffer',
243239 category = 'lsp',
244240 keys = '<c-s>',
245241 command = vim.lsp.buf.format,
246242 }
248244 map.normal {
249 name = 'Show hover documentation above cursor.',
245 description = 'Show hover documentation above cursor.',
250246 category = 'lsp',
251247 keys = '<c-0>',
252248 command = vim.lsp.buf.hover,
253249 }
255251 map.normal {
256 name = 'Show implementations of symbol under cursor.',
252 description = 'Show implementations of symbol under cursor.',
257253 category = 'lsp',
258254 keys = '<c-4>',
259255 command = vim.lsp.buf.implementation,
260256 }
261257 map.normal {
262 name = 'Show implementations of symbol under cursor.',
258 description = 'Show implementations of symbol under cursor.',
263259 category = 'telescope',
264260 keys = '<c-4><c-4>',
265261 command = '<cmd>Telescope lsp_implementations<cr>',
266262 }
268264 map.normal {
269 name = 'Show incoming calls of symbol under cursor.',
265 description = 'Show incoming calls of symbol under cursor.',
270266 category = 'lsp',
271267 keys = '<c-5>',
272268 command = vim.lsp.buf.incoming_calls,
273269 }
274270 map.normal {
275 name = 'Show incoming calls of symbol under cursor.',
271 description = 'Show incoming calls of symbol under cursor.',
276272 category = 'telescope',
277273 keys = '<c-5><c-5>',
278274 command = '<cmd>Telescope lsp_incoming_calls<cr>',
279275 }
280276 map.normal {
281 name = 'Show outgoing calls of symbol under cursor.',
277 description = 'Show outgoing calls of symbol under cursor.',
282278 category = 'lsp',
283279 keys = '<c-s-5>',
284280 command = vim.lsp.buf.outgoing_calls,
285281 }
286282 map.normal {
287 name = 'Show outgoing calls of symbol under cursor.',
283 description = 'Show outgoing calls of symbol under cursor.',
288284 category = 'telescope',
289285 keys = '<c-s-5><c-s-5>',
290286 command = '<cmd>Telescope lsp_outgoing_calls<cr>',
291287 }
293289 map.normal {
294 name = 'Show references of symbol under cursor.',
290 description = 'Show references of symbol under cursor.',
295291 category = 'lsp',
296292 keys = '<c-6>',
297293 command = vim.lsp.buf.references,
298294 }
299295 map.normal {
300 name = 'Show references of symbol under cursor.',
296 description = 'Show references of symbol under cursor.',
301297 category = 'telescope',
302298 keys = '<c-6><c-6>',
303299 command = vim.lsp.buf.references,
304300 }
306302 map.normal {
307 name = 'Rename symbol under cursor.',
303 description = 'Rename symbol under cursor.',
308304 category = 'lsp',
309305 keys = '<c-9>',
310306 command = vim.lsp.buf.rename,
311307 }
313309 map.normal {
314 name = 'Show signature help under cursor.',
310 description = 'Show signature help under cursor.',
315311 category = 'lsp',
316312 keys = '<c-s-0>',
317313 command = vim.lsp.buf.signature_help,
318314 }
320316 map.normal {
321 name = 'Show signature help under cursor.',
317 description = 'Show signature help under cursor.',
322318 category = 'telescope',
323319 keys = '<c-s-0><c-s-0>',
324320 command = '<cmd>Telescope lsp_signature_help<cr>',
415411 desc = 'Shows detailed information about running LSP clients.',
416412} )
418return setmetatable( _, {} )
414return setmetatable( _, {} )No final newline

neovim/lua/bugabinga/lsp/lightbulb.lua

Added
new file mode 100644

+129 / −0 text lines

1--VSCode-like lightbulb.
2--Implementation inspired from https://github.com/nvimdev/lspsaga.nvim/blob/c9b17bc7dc694bdbeb3788a583518073a30a6de2/lua/lspsaga/codeaction/lightbulb.lua
3
4local lb_name = 'mariasolos/lightbulb'
5local lb_namespace = vim.api.nvim_create_namespace( lb_name )
6local lb_icon = require 'std.icon'.hint
7local lb_group = vim.api.nvim_create_augroup( lb_name, { clear = true } )
8local code_action_method = vim.lsp.protocol.Methods.textDocument_codeAction
9local timer = vim.uv.new_timer()
10local updated_bufnr = nil
12---Updates the current lightbulb.
13---@param bufnr number?
14---@param line number?
15local function update_extmark( bufnr, line )
16 if not bufnr or not vim.api.nvim_buf_is_valid( bufnr ) then
17 return
18 end
20 vim.api.nvim_buf_clear_namespace( bufnr, lb_namespace, 0, -1 )
22 -- Extra check for not being in insert mode here because sometimes the autocommand
23 -- fails with motions from Comment.nvim.
24 if not line or vim.api.nvim_get_mode().mode:sub( 1, 1 ) == 'i' then
25 return
26 end
28 vim.api.nvim_buf_set_extmark( bufnr, lb_namespace, line, -1, {
29 virt_text = { { ' ' .. lb_icon, 'DiagnosticSignHint' } },
30 hl_mode = 'combine',
31 } )
33 updated_bufnr = bufnr
34end
36---Queries the LSP servers for code actions and updates the lightbulb
37---accordingly.
38---@param bufnr number
39local function render( bufnr )
40 local line = vim.api.nvim_win_get_cursor( 0 )[1] - 1
41 local diagnostics = vim.diagnostic.get( bufnr, { lnum = line } )
43 -- If there are hints in the current line, don't show yet another lightbulb.
44 if
45 vim.iter( diagnostics ):any( function ( diag )
46 return diag.severity == vim.diagnostic.severity.HINT
47 end )
48 then
49 update_extmark( bufnr, nil )
50 return
51 end
53 local params = vim.lsp.util.make_range_params()
54 params.context = {
55 diagnostics = diagnostics,
56 triggerKind = vim.lsp.protocol.CodeActionTriggerKind.Automatic,
57 }
59 vim.lsp.buf_request( bufnr, code_action_method, params, function ( _, res, _ )
60 if vim.api.nvim_get_current_buf() ~= bufnr then
61 return
62 end
64 update_extmark( bufnr, (res and #res > 0 and line) or nil )
65 end )
66end
68-- I don't fully understand how this works, kind of just copy-pasted it
69-- from lspsaga.
70---@param bufnr number
71local function update( bufnr )
72 assert( timer, 'Timer is not initialized' )
74 timer:stop()
75 update_extmark( updated_bufnr )
76 timer:start( 100, 0, function ()
77 timer:stop()
78 vim.schedule( function ()
79 if vim.api.nvim_buf_is_valid( bufnr ) and vim.api.nvim_get_current_buf() == bufnr then
80 render( bufnr )
81 end
82 end )
83 end )
84end
86vim.api.nvim_create_autocmd( 'LspAttach', {
87 group = lb_group,
88 desc = 'Configure code action lightbulb',
89 callback = function ( event )
90 local buf = event.buf
91 local client = vim.lsp.get_client_by_id( event.data.client_id )
93 if not client or not client.supports_method( code_action_method ) then
94 return
95 end
97 local buf_group_name = lb_name .. tostring( buf )
98 if pcall( vim.api.nvim_get_autocmds, { group = buf_group_name, buffer = buf } ) then
99 return
100 end
102 local lb_buf_group = vim.api.nvim_create_augroup( buf_group_name, { clear = true } )
103 vim.api.nvim_create_autocmd( 'CursorMoved', {
104 group = lb_buf_group,
105 desc = 'Update lightbulb when moving the cursor in normal/visual mode',
106 buffer = buf,
107 callback = function ()
108 update( buf )
109 end,
110 } )
112 vim.api.nvim_create_autocmd( { 'InsertEnter', 'BufLeave' }, {
113 group = lb_buf_group,
114 desc = 'Update lightbulb when entering insert mode or leaving the buffer',
115 buffer = event.buf,
116 callback = function ()
117 update_extmark( buf, nil )
118 end,
119 } )
120 end,
121} )
123vim.api.nvim_create_autocmd( 'LspDetach', {
124 group = lb_group,
125 desc = 'Detach code action lightbulb',
126 callback = function ( event )
127 pcall( vim.api.nvim_del_augroup_by_name, lb_name .. tostring( event.buf ) )
128 end,
129} )

neovim/lua/bugabinga/mark.lua

Added
new file mode 100644

+197 / −0 text lines

1-- Custom mark API.
2-- Implementation slightly inspired by https://github.com/chentoast/marks.nvim, but this is
3-- much simpler.
4
5---Map of mark information per buffer.
6---@type table<integer, table<string, {line: integer, id: integer}>>
7local marks = {}
8
9---Keeps track of the signs I've already created.
10---@type table<string, boolean>
11local sign_cache = {}
13---The sign and autocommand group name.
14local sign_group_name = 'MarksSigns'
16---@param mark string
17local function is_lowercase_mark( mark )
18 return 97 <= mark:byte() and mark:byte() <= 122
19end
21---@param mark string
22local function is_uppercase_mark( mark )
23 return 65 <= mark:byte() and mark:byte() <= 90
24end
26---@param mark string
27local function is_letter_mark( mark )
28 return is_lowercase_mark( mark ) or is_uppercase_mark( mark )
29end
31---@param mark string
32---@param bufnr integer
33local function delete_mark( mark, bufnr )
34 local buffer_marks = marks[bufnr]
36 if not buffer_marks or not buffer_marks[mark] then
37 return
38 end
40 vim.fn.sign_unplace( sign_group_name, { buffer = bufnr, id = buffer_marks[mark].id } )
41 buffer_marks[mark] = nil
43 if is_letter_mark( mark ) then
44 vim.cmd( 'delmarks ' .. mark )
45 end
46end
48---@param mark string
49---@param bufnr integer
50---@param line? integer
51local function register_mark( mark, bufnr, line )
52 local buffer_marks = marks[bufnr]
54 if not buffer_marks then
55 return
56 end
58 if buffer_marks[mark] then
59 -- Mark already exists, remove it first.
60 delete_mark( mark, bufnr )
61 end
63 -- Add the sign to the tracking table.
64 local id = mark:byte() * 100
65 line = line or vim.api.nvim_win_get_cursor( 0 )[1]
66 buffer_marks[mark] = { line = line, id = id }
68 -- Create the sign.
69 local sign_name = 'Marks_' .. mark
70 if not sign_cache[sign_name] then
71 vim.fn.sign_define( sign_name, { text = mark, texthl = 'DiagnosticSignOk' } )
72 sign_cache[sign_name] = true
73 end
74 vim.fn.sign_place( id, sign_group_name, sign_name, bufnr, {
75 lnum = line,
76 priority = 10,
77 } )
78end
80---@param bufnr integer
81local function set_keymaps( bufnr )
82 vim.api.nvim_buf_set_keymap( bufnr, 'n', '<leader>m', '', {
83 desc = 'Add mark',
84 callback = function ()
85 local ok, mark = pcall( function ()
86 return vim.fn.getcharstr()
87 end )
88 if not ok then
89 return
90 end
92 if is_letter_mark( mark ) then
93 register_mark( mark, bufnr )
94 vim.cmd( 'normal! m' .. mark )
95 end
96 end,
97 } )
99 vim.api.nvim_buf_set_keymap( bufnr, 'n', '<leader>dm', '', {
100 desc = 'Delete mark',
101 callback = function ()
102 local ok, mark = pcall( function ()
103 return vim.fn.getcharstr()
104 end )
105 if not ok then
106 return
107 end
109 if is_letter_mark( mark ) then
110 delete_mark( mark, bufnr )
111 end
112 end,
113 } )
115 vim.api.nvim_buf_set_keymap( bufnr, 'n', '<leader>dM', '', {
116 desc = 'Delete all buffer marks',
117 callback = function ()
118 -- NOTE: This will delete the builtin marks too, but I'll restore
119 -- them on cursor move so whatever.
120 marks[bufnr] = {}
121 vim.fn.sign_unplace( sign_group_name, { buffer = bufnr } )
122 vim.cmd 'delmarks!'
123 end,
124 } )
125end
127---@param bufnr integer
128local function refresh_builtin_marks( bufnr )
129 for _, builtin_mark in ipairs { '.', '`' } do
130 local pos = vim.fn.getpos( "'" .. builtin_mark )
131 local cached_mark = marks[bufnr][builtin_mark]
132 if (pos[1] == 0 or pos[1] == bufnr) and pos[2] ~= 0 and (not cached_mark or pos[2] ~= cached_mark.line) then
133 register_mark( builtin_mark, bufnr, pos[2] )
134 end
135 end
136end
138vim.api.nvim_create_autocmd( 'BufWinEnter', {
139 group = vim.api.nvim_create_augroup( sign_group_name, { clear = true } ),
140 desc = 'Configure mark signs',
141 callback = function ( event )
142 local bufnr = event.buf
143 -- Only handle normal buffers.
144 if vim.bo[bufnr].bt ~= '' then
145 return
146 end
148 -- Set custom mappings.
149 set_keymaps( bufnr )
151 if not marks[bufnr] then
152 marks[bufnr] = {}
153 end
155 -- Remove all marks that were deleted.
156 for mark, _ in pairs( marks[bufnr] ) do
157 if vim.api.nvim_buf_get_mark( bufnr, mark )[1] == 0 then
158 delete_mark( mark, bufnr )
159 end
160 end
162 -- Register the letter marks.
163 for _, data in ipairs( vim.fn.getmarklist() ) do
164 local mark = data.mark:sub( 2, 3 )
165 local pos = data.pos
166 local cached_mark = marks[bufnr][mark]
168 if is_uppercase_mark( mark ) and pos[1] == bufnr and (not cached_mark or pos[2] ~= cached_mark.line) then
169 register_mark( mark, bufnr, pos[2] )
170 end
171 end
172 for _, data in ipairs( vim.fn.getmarklist '%' ) do
173 local mark = data.mark:sub( 2, 3 )
174 local pos = data.pos
175 local cached_mark = marks[bufnr][mark]
177 if is_lowercase_mark( mark ) and (not cached_mark or pos[2] ~= cached_mark.line) then
178 register_mark( mark, bufnr, pos[2] )
179 end
180 end
182 local buf_group_name = sign_group_name .. tostring( bufnr )
183 if pcall( vim.api.nvim_get_autocmds, { group = buf_group_name, buffer = bufnr } ) then
184 return
185 end
186 refresh_builtin_marks( bufnr )
187 local marks_buf_group = vim.api.nvim_create_augroup( buf_group_name, { clear = true } )
188 vim.api.nvim_create_autocmd( 'CursorMoved', {
189 group = marks_buf_group,
190 desc = 'Refresh signs for builtin marks',
191 buffer = bufnr,
192 callback = function ()
193 refresh_builtin_marks( bufnr )
194 end,
195 } )
196 end,
197} )

neovim/lua/bugabinga/nugu/init.lua

Modified

+63 / −49 text lines

173173 LspReferenceText { fg = content_focus, bg = content_unfocus },
174174 LspReferenceRead { LspReferenceText },
175175 LspReferenceWrite { LspReferenceText },
176 LspInlayHint { fg = content_minor, bg = ui_unfocus },
177178 -- hlargs.nvim
178179 Hlargs { fg = ui_important_local },
194195 --
195196 -- For more information see https://github.com/rktjmp/lush.nvim/issues/109
197 sym"@text.literal" { }, -- Comment
198 sym"@text.reference" { }, -- Identifier
199 sym"@text.title" { }, -- Title
200 sym"@text.uri" { }, -- Underlined
201 sym"@text.underline" { }, -- Underlined
202 sym"@text.todo" { }, -- Todo
203 sym"@comment" { }, -- Comment
204 sym"@punctuation" { }, -- Delimiter
205 sym"@constant" { }, -- Constant
206 sym"@constant.builtin" { }, -- Special
207 sym"@constant.macro" { }, -- Define
208 sym"@define" { }, -- Define
209 sym"@macro" { }, -- Macro
210 sym"@string" { }, -- String
211 sym"@string.escape" { }, -- SpecialChar
212 sym"@string.special" { }, -- SpecialChar
213 sym"@character" { }, -- Character
214 sym"@character.special" { }, -- SpecialChar
215 sym"@number" { }, -- Number
216 sym"@boolean" { }, -- Boolean
217 sym"@float" { }, -- Float
218 sym"@function" { }, -- Function
219 sym"@function.builtin" { }, -- Special
220 sym"@function.macro" { }, -- Macro
221 sym"@parameter" { }, -- Identifier
222 sym"@method" { }, -- Function
223 sym"@field" { }, -- Identifier
224 sym"@property" { }, -- Identifier
225 sym"@constructor" { }, -- Special
226 sym"@conditional" { }, -- Conditional
227 sym"@repeat" { }, -- Repeat
228 sym"@label" { }, -- Label
229 sym"@operator" { }, -- Operator
230 sym"@keyword" { }, -- Keyword
231 sym"@exception" { }, -- Exception
232 sym"@variable" { }, -- Identifier
233 sym"@type" { }, -- Type
234 sym"@type.definition" { }, -- Typedef
235 sym"@storageclass" { }, -- StorageClass
236 sym"@structure" { }, -- Structure
237 sym"@namespace" { }, -- Identifier
238 sym"@include" { }, -- Include
239 sym"@preproc" { }, -- PreProc
240 sym"@debug" { }, -- Debug
241 sym"@tag" { }, -- Tag
198 sym '@text.literal' { Comment },
199 sym '@text.reference' { Identifier },
200 sym '@text.title' { Title },
201 sym '@text.underline' { Underlined },
202 sym '@text.todo' { Todo },
203 sym '@comment' { Comment },
204 sym '@punctuation' { Delimiter },
205 sym '@constant' { Constant },
206 sym '@constant.builtin' { Special },
207 sym '@constant.macro' { Define },
208 sym '@define' { Define },
209 sym '@macro' { Macro },
210 sym '@string' { String },
211 sym '@string.escape' { SpecialChar },
212 sym '@string.special' { SpecialChar },
213 sym '@character' { Character },
214 sym '@character.special' { SpecialChar },
215 sym '@number' { Number },
216 sym '@boolean' { Boolean },
217 sym '@float' { Float },
218 sym '@function' { Function },
219 sym '@function.builtin' { Special },
220 sym '@function.macro' { Macro },
221 sym '@parameter' { Identifier },
222 sym '@method' { Function },
223 sym '@field' { Identifier },
224 sym '@property' { Identifier },
225 sym '@constructor' { Special },
226 sym '@conditional' { Conditional },
227 sym '@repeat' { Repeat },
228 sym '@label' { Label },
229 sym '@operator' { Operator },
230 sym '@keyword' { Keyword },
231 sym '@exception' { Exception },
232 sym '@variable' { Identifier },
233 sym '@type' { Type },
234 sym '@type.definition' { Typedef },
235 sym '@storageclass' { StorageClass },
236 sym '@structure' { Structure },
237 sym '@namespace' { Identifier },
238 sym '@include' { Include },
239 sym '@preproc' { PreProc },
240 sym '@debug' { Debug },
241 sym '@tag' { Tag },
243 sym '@lsp.type.namespace' { sym '@namespace' },
244 sym '@lsp.type.type' { sym '@type' },
245 sym '@lsp.type.class' { sym '@type' },
246 sym '@lsp.type.enum' { sym '@type' },
247 sym '@lsp.type.interface' { sym '@type' },
248 sym '@lsp.type.struct' { sym '@structure' },
249 sym '@lsp.type.parameter' { sym '@parameter' },
250 sym '@lsp.type.variable' { sym '@variable' },
251 sym '@lsp.type.property' { sym '@property' },
252 sym '@lsp.type.enumMember' { sym '@constant' },
253 sym '@lsp.type.function' { sym '@function' },
254 sym '@lsp.type.method' { sym '@method' },
255 sym '@lsp.type.macro' { sym '@macro' },
256 sym '@lsp.type.decorator' { sym '@function' },
243258 -- lazy.nvim
244259 LazyButton { NormalFloat, sp = NormalFloat.fg, gui = 'bold' },
394409 TelescopeMultiSelection { fg = PmenuSel.fg, bg = ui_important_local },
396411 FlashBackdrop {},
397 FlashMatch { Search },
398 FlashCurrent { IncSearch },
399 FlashLabel { gui = 'reverse' },
412 FlashMatch { bg = content_unfocus },
413 FlashCurrent { fg = content_accent, bg = content_unfocus },
414 FlashLabel { fg = Search.bg, bg = Search.fg },
401416 GitSignsAdd { fg = DiffAdd.fg, bg = ui_backdrop },
402417 GitSignsChange { fg = DiffChange.fg, bg = ui_backdrop },
436451 GitSignsDeleteVirtLnInLine { DiffText },
437452 GitSignsVirtLnum { fg = LineNr.fg },
439 MultiCursorMain { fg = content_important_local, bg = content_unfocus, gui = "bold"}
440454 }
441455end )

neovim/lua/bugabinga/options/keymaps.lua

Modified

+19 / −19 text lines

1local map = require 'std.keymap'
1local map = require 'std.map'
22local want = require 'std.want'
44-- set <SPACE> as leader key
1919-- insert newline under or above in normal mode
2020map.normal {
21 name = 'Insert newline under cursor',
21 description = 'Insert newline under cursor',
2222 category = 'editing',
2323 keys = '<C-enter>',
2424 command = function()
3333map.normal {
34 name = 'Insert newline above cursor',
34 description = 'Insert newline above cursor',
3535 category = 'editing',
3636 keys = '<C-S-enter>',
3737 command = function()
8888-- system clipboard copy and paste
8989map.normal.visual {
90 name = 'yank into system clipboard',
90 description = 'yank into system clipboard',
9191 category = 'editing',
9292 keys = '<leader>y',
9393 command = '"+y',
9696map.normal.visual {
97 name = 'yank line into system clipboard',
97 description = 'yank line into system clipboard',
9898 category = 'editing',
9999 keys = '<leader>yy',
100100 command = '"+Y',
103103map.normal.visual {
104 name = 'paste before from system clipboard',
104 description = 'paste before from system clipboard',
105105 category = 'editing',
106106 keys = '<leader>p',
107107 command = '"+p',
110110map.normal.visual {
111 name = 'paste after from system clipboard',
111 description = 'paste after from system clipboard',
112112 category = 'editing',
113113 keys = '<leader>P',
114114 command = '"+P',
117117map.insert {
118 name = 'Cycle through autocomplete popup',
118 description = 'Cycle through autocomplete popup',
119119 category = 'editing',
120120 keys = '<tab>',
121121 options = { expr = true },
140140end
142142map.normal {
143 name = 'Open web link under cursor in browser',
143 description = 'Open web link under cursor in browser',
144144 category = 'navigation',
145145 keys = 'gx',
146146 command = open_link_under_cursor,
149149map.normal {
150 name = 'Dismiss current search highlight',
150 description = 'Dismiss current search highlight',
151151 category = 'search',
152152 keys = '<esc><esc>',
153153 command = function() vim.cmd [[ nohlsearch ]] end,
170170map.insert {
171 name = 'Exit normal mode',
171 description = 'Exit normal mode',
172172 category = 'vim',
173173 keys = 'jj',
174174 command = '<C-c>',
177177map.normal {
178 name = 'Goto matching bracket',
178 description = 'Goto matching bracket',
179179 category = 'navigation',
180180 keys = 'mm',
181181 command = '%',
184184map.normal {
185 name = 'Redo undone operation',
185 description = 'Redo undone operation',
186186 category = 'history',
187187 keys = 'U',
188188 command = vim.cmd.redo,
196196map.normal {
197 name = 'Move next in quickfix list',
197 description = 'Move next in quickfix list',
198198 category = 'navigation',
199199 keys = '<A-bs>',
200200 command = '<cmd>cnext<cr>',
203203map.normal {
204 name = 'Move back in quickfix list',
204 description = 'Move back in quickfix list',
205205 category = 'navigation',
206206 keys = '<bs>',
207207 command = '<cmd>cprevious<cr>',
210210map.normal {
211 name = 'Open quickfix list',
211 description = 'Open quickfix list',
212212 category = 'navigation',
213213 keys = '<bs><bs>',
214214 command = '<cmd>copen<cr>',
217217map.normal {
218 name = 'Open nvim configuration',
218 description = 'Open nvim configuration',
219219 category = 'config',
220220 keys = '<F2><F2>',
221221 command = '<cmd>tabedit ' .. vim.fn.stdpath'config' .. '<cr>',
224224map.normal {
225 name = 'Execute current line as lua in neovim',
225 description = 'Execute current line as lua in neovim',
226226 category = 'config',
227227 keys = '<cr><cr>',
228228 command = '<cmd>lua <c-r><c-l><cr>'
229}
229}No final newline

neovim/lua/bugabinga/options/ui.lua

Modified

+4 / −4 text lines

8484-- neovide only options
8585if vim.g.neovide then
86 vim.g.neovide_floating_blur_amount_x = 4.0
86 vim.g.neovide_floating_blur_amount_x = 8.0
8787 vim.g.neovide_floating_blur_amount_y = 4.0
8888 vim.g.neovide_scroll_animation_length = 0.42
8989 -- vim.g.neovide_fullscreen = true
9090 vim.g.neovide_remember_window_size = true
9191 vim.g.neovide_profiler = false
9292 vim.g.neovide_cursor_animation_length = 0.11
93 vim.g.neovide_cursor_trail_length = 0.69
93 vim.g.neovide_cursor_trail_length = 1.69
9494 vim.g.neovide_cursor_vfx_mode = 'pixiedust'
9595 vim.g.neovide_cursor_unfocused_outline_width = 0.125
9696 vim.g.neovide_cursor_antialiasing = true
9898 vim.g.neovide_padding_bottom = 0
9999 vim.g.neovide_padding_right = 1
100100 vim.g.neovide_padding_left = 1
101 vim.g.neovide_hide_mouse_when_typing = false
101 vim.g.neovide_hide_mouse_when_typing = true
102102 vim.g.neovide_theme = 'auto'
103 vim.g.neovide_refresh_rate = 60
103 vim.g.neovide_refresh_rate = vim.uv.os_gethostname() == 'pop-os' and 144 or 60
104104 vim.g.neovide_refresh_rate_idle = 5
105105end

neovim/lua/bugabinga/plugins/cmp.lua

Added
new file mode 100644

+93 / −0 text lines

1---@diagnostic disable: missing-fields
2
3return {
4 'hrsh7th/nvim-cmp',
5 event = 'InsertEnter',
6 dependencies = {
7 'hrsh7th/cmp-buffer',
8 'hrsh7th/cmp-nvim-lsp',
9 'hrsh7th/cmp-cmdline',
10 'hrsh7th/cmp-path',
11 { 'L3MON4D3/LuaSnip', version = '2.*', build = 'make install_jsregexp' },
12 'saadparwaiz1/cmp_luasnip',
13 'rafamadriz/friendly-snippets',
14 'onsails/lspkind.nvim',
15 },
16 config = function ()
17 local cmp = require 'cmp'
18 local luasnip = require 'luasnip'
19 local lspkind = require 'lspkind'
21 require 'luasnip.loaders.from_vscode'.lazy_load()
23 cmp.setup {
24 completion = {
25 autocomplete = false,
26 completeopt = 'menu,menuone,preview,noselect',
27 },
28 formatting = {
29 format = lspkind.cmp_format {
30 mode = 'symbol',
31 maxwidth = 75,
32 ellipsis_char = '…',
33 },
34 },
35 snippet = { expand = function ( args ) luasnip.lsp_expand( args.body ) end },
36 mapping = {
37 ['<c-p>'] = cmp.mapping.select_prev_item(),
38 ['<c-n>'] = cmp.mapping.select_next_item(),
39 ['<c-k>'] = cmp.mapping.select_prev_item(),
40 ['<c-j>'] = cmp.mapping.select_next_item(),
41 ['<s-tab>'] = cmp.mapping.select_prev_item(),
42 ['<tab>'] = cmp.mapping.select_next_item(),
43 ['<c-b>'] = cmp.mapping.scroll_docs( -2 ),
44 ['<c-f>'] = cmp.mapping.scroll_docs( 2 ),
45 ['<c-u>'] = cmp.mapping.scroll_docs( -4 ),
46 ['<c-d>'] = cmp.mapping.scroll_docs( 4 ),
47 ['<c-space>'] = cmp.mapping.complete {},
48 ['<esc>'] = cmp.mapping.abort(),
49 ['<cr>'] = cmp.mapping.confirm { select = false }
50 },
51 sources = cmp.config.sources {
52 { name = 'luasnip' },
53 { name = 'nvim_lsp' },
54 { name = 'buffer' },
55 { name = 'path' },
56 }
57 }
59 cmp.setup.filetype( 'gitcommit', {
60 sources = cmp.config.sources {
61 { name = 'git' },
62 },
63 {
64 { name = 'buffer' },
65 { name = 'path' },
66 }
67 } )
69 cmp.setup.cmdline( '/', {
70 mapping = cmp.mapping.preset.cmdline(),
71 sources = {
72 { name = 'buffer' }
73 }
74 } )
76 cmp.setup.cmdline( '?', {
77 mapping = cmp.mapping.preset.cmdline(),
78 sources = {
79 { name = 'buffer' }
80 }
81 } )
83 cmp.setup.cmdline( ':', {
84 mapping = cmp.mapping.preset.cmdline(),
85 sources = cmp.config.sources {
86 { name = 'path' }
87 },
88 {
89 { name = 'cmdline' }
90 }
91 } )
92 end,
93}

neovim/lua/bugabinga/plugins/flash.lua

Modified

+19 / −8 text lines

11return {
22 'folke/flash.nvim',
3 event = "VeryLazy",
4 opts = {},
3 event = 'VeryLazy',
4 opts = {
5 highlight = { backdrop = false },
6 modes = { char = { highlight = { backdrop = false, } },
7 },
8 },
59 keys = {
6 { "<cr>", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
7 { "<s-cr>", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
8 { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
9 { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
10 { "<cr><cr>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
10 {
11 '<cr>',
12 mode = { 'n', 'x', 'o' },
13 function () require 'flash'.jump() end,
14 desc = 'Flash',
15 },
16 {
17 '<s-cr>',
18 mode = { 'n', 'o', 'x' },
19 function () require 'flash'.treesitter() end,
20 desc =
21 'Flash Treesitter'
22 },
1123 },

neovim/lua/bugabinga/plugins/genghis.lua

Modified

+59 / −19 text lines

11return {
22 {
33 'chrisgrieser/nvim-genghis',
4 dependencies = {
5 'stevearc/dressing.nvim',
6 'hrsh7th/nvim-cmp',
7 'hrsh7th/cmp-omni',
8 'anuvyklack/hydra.nvim',
9 },
10 keys = { '<leader>g' },
411 cmd = {
512 'New',
613 'Duplicate',
1219 'CopyFilepath',
1320 'Chmodx',
1421 },
15 config = function()
16 -- TODO: setup cmp integration
22 config = function ()
23 local genghis = require 'genghis'
24 local cmp = require 'cmp'
25 local hydra = require 'hydra'
18 -- TODO: setup keymaps with hydra
19 -- local keymap = vim.keymap.set
20 -- local genghis = require("genghis")
21 -- keymap("n", "<leader>yp", genghis.copyFilepath)
22 -- keymap("n", "<leader>yn", genghis.copyFilename)
23 -- keymap("n", "<leader>cx", genghis.chmodx)
24 -- keymap("n", "<leader>rf", genghis.renameFile)
25 -- keymap("n", "<leader>mf", genghis.moveAndRenameFile)
26 -- keymap("n", "<leader>nf", genghis.createNewFile)
27 -- keymap("n", "<leader>yf", genghis.duplicateFile)
28 -- keymap("n", "<leader>df", function () genghis.trashFile{trashLocation = "your/path"} end) -- default: "$HOME/.Trash".
29 -- keymap("x", "<leader>x", genghis.moveSelectionToNewFile)
27 cmp.setup.filetype( 'DressingInput', {
28 sources = cmp.config.sources { { name = 'omni' } },
29 } )
31 local hint = [[
32^ Ghenigs
33^
34_yp_ copy filepath
35_yn_ copy filename
36_cx_ set executable permission
37_rf_ rename file
38_mf_ move and rename file
39_nf_ create new file
40_df_ duplicate file
41_tf_ trash file
42_ms_ move selection to new file
43^
44_<esc>_ quit
45]]
47 hydra {
48 name = 'Genghis',
49 hint = hint,
50 config = {
51 color = 'teal',
52 invoke_on_body = true,
53 buffer = true,
54 hint = {
55 type = 'window',
56 border = vim.g.border_style,
57 position = 'middle',
58 }
59 },
60 mode = { 'n', 'x' },
61 body = '<leader>g',
62 heads = {
63 { 'yp', genghis.copyFilepath, },
64 { 'yn', genghis.copyFilename, },
65 { 'cx', genghis.chmodx, },
66 { 'rf', genghis.renameFile, },
67 { 'mf', genghis.moveAndRenameFile, },
68 { 'nf', genghis.createNewFile, },
69 { 'df', genghis.duplicateFile, },
70 { 'tf', genghis.trashFile, },
71 { 'ms', genghis.moveSelectionToNewFile },
72 { '<esc>', nil },
73 },
74 }
3075 end,
31 dependencies = {
32 'stevearc/dressing.nvim',
33 'hrsh7th/nvim-cmp',
34 'hrsh7th/cmp-omni',
35 },
3676 },

neovim/lua/bugabinga/plugins/gomove.lua

Modified

+18 / −18 text lines

1local map = require 'std.keymap'
1local map = require 'std.map'
33return {
44 {
3939 -- NORMAL MOVE
4040 map.normal {
41 name = 'Move character left',
41 description = 'Move character left',
4242 category = 'editing',
4343 keys = '<A-h>',
4444 options = options,
4545 command = '<Plug>GoNSMLeft',
4646 }
4747 map.normal {
48 name = 'Move line down',
48 description = 'Move line down',
4949 category = 'editing',
5050 keys = '<A-j>',
5151 options = options,
5252 command = '<Plug>GoNSMDown',
5353 }
5454 map.normal {
55 name = 'Move line up',
55 description = 'Move line up',
5656 category = 'editing',
5757 keys = '<A-k>',
5858 options = options,
5959 command = '<Plug>GoNSMUp',
6060 }
6161 map.normal {
62 name = 'Move character right',
62 description = 'Move character right',
6363 category = 'editing',
6464 keys = '<A-l>',
6565 options = options,
6969 -- VISUAL MOVE
7070 map.visual {
71 name = 'Move block left',
71 description = 'Move block left',
7272 category = 'editing',
7373 keys = '<A-h>',
7474 options = options,
7575 command = '<Plug>GoVSMLeft',
7676 }
7777 map.visual {
78 name = 'Move block down',
78 description = 'Move block down',
7979 category = 'editing',
8080 keys = '<A-j>',
8181 options = options,
8282 command = '<Plug>GoVSMDown',
8383 }
8484 map.visual {
85 name = 'Move block up',
85 description = 'Move block up',
8686 category = 'editing',
8787 keys = '<A-k>',
8888 options = options,
8989 command = '<Plug>GoVSMUp',
9090 }
9191 map.visual {
92 name = 'Move block right',
92 description = 'Move block right',
9393 category = 'editing',
9494 keys = '<A-l>',
9595 options = options,
9999 -- NORMAL DUPLICATE
100100 map.normal {
101 name = 'Duplicate character left',
101 description = 'Duplicate character left',
102102 category = 'editing',
103103 keys = '<A-H>',
104104 options = options,
105105 command = '<Plug>GoNSDLeft',
106106 }
107107 map.normal {
108 name = 'Duplicate line down',
108 description = 'Duplicate line down',
109109 category = 'editing',
110110 keys = '<A-J>',
111111 options = options,
112112 command = '<Plug>GoNSDDown',
113113 }
114114 map.normal {
115 name = 'Duplicate line up',
115 description = 'Duplicate line up',
116116 category = 'editing',
117117 keys = '<A-K>',
118118 options = options,
119119 command = '<Plug>GoNSDUp',
120120 }
121121 map.normal {
122 name = 'Duplicate character right',
122 description = 'Duplicate character right',
123123 category = 'editing',
124124 keys = '<A-L>',
125125 options = options,
129129 -- VISUAL DUPLICATE
130130 map.visual {
131 name = 'Duplicate block left',
131 description = 'Duplicate block left',
132132 category = 'editing',
133133 keys = '<A-H>',
134134 options = options,
135135 command = '<Plug>GoVSDLeft',
136136 }
137137 map.visual {
138 name = 'Duplicate block down',
138 description = 'Duplicate block down',
139139 category = 'editing',
140140 keys = '<A-J>',
141141 options = options,
142142 command = '<Plug>GoVSDDown',
143143 }
144144 map.visual {
145 name = 'Duplicate block up',
145 description = 'Duplicate block up',
146146 category = 'editing',
147147 keys = '<A-K>',
148148 options = options,
149149 command = '<Plug>GoVSDUp',
150150 }
151151 map.visual {
152 name = 'Duplicate block right',
152 description = 'Duplicate block right',
153153 category = 'editing',
154154 keys = '<A-L>',
155155 options = options,
157157 }
158158 end,
159159 },
160}
160}No final newline

neovim/lua/bugabinga/plugins/neoclip.lua

Modified

+3 / −3 text lines

1local map = require'std.keymap'
1local map = require'std.map'
33return {
44 'AckslD/nvim-neoclip.lua',
1717 telescope.load_extension'neoclip'
1919 map.normal {
20 name = 'Open clipboard history...',
20 description = 'Open clipboard history...',
2121 category = 'history',
2222 keys = '<C-v><C-v>',
2323 command = function() telescope.extensions.neoclip.default(cursor) end,
2424 }
2626 end,
27}
27}No final newline

neovim/lua/bugabinga/plugins/neogen.lua

Modified

+5 / −5 text lines

1local map = require'std.keymap'
1local map = require'std.map'
33return {
44 'danymat/neogen',
1010 neogen.setup { }
1212 map.normal {
13 name = 'Generate doc comment for outer element',
13 description = 'Generate doc comment for outer element',
1414 category = 'editing',
1515 keys = '<A-enter>',
1616 command = neogen.generate,
2424 }
2626 map.normal {
27 name = 'Generate Doc Comment for File',
27 description = 'Generate Doc Comment for File',
2828 category = "editing",
2929 keys = '<A-enter>' .. 'F',
3030 command = function() neogen.generate { type = 'file' } end,
3131 }
3333 map.normal {
34 name = 'Generate Doc Comment for Class',
34 description = 'Generate Doc Comment for Class',
3535 category = "editing",
3636 keys = '<A-enter>' .. 'c',
3737 command = function() neogen.generate { type = 'class' } end,
3838 }
4040 end,
41}
41}No final newline

neovim/lua/bugabinga/plugins/noice.lua

Modified

+7 / −7 text lines

1local map = require'std.keymap'
1local map = require'std.map'
33return {
44 {
9090 noice.setup(opts)
9292 map.normal {
93 name = 'Open search for notifications...',
93 description = 'Open search for notifications...',
9494 category = 'search',
9595 keys = '<C-n><C-n>',
9696 command = function() noice.cmd'history' end,
9797 }
9999 map.command_line {
100 name = 'Redirect Cmdline',
100 description = 'Redirect Cmdline',
101101 category = 'ui',
102102 keys = '<S-cr>',
103103 command = function() noice.redirect(vim.fn.getcmdline()) end,
104104 }
106106 map.normal {
107 name = 'Dismiss current notifications',
107 description = 'Dismiss current notifications',
108108 category = 'notify',
109109 keys = '<esc>',
110110 command = function() noice.cmd 'dismiss' end,
113113 local noice_lsp = require'noice.lsp'
115115 map.normal {
116 name = 'Scroll up in documentation popup',
116 description = 'Scroll up in documentation popup',
117117 category = 'ui',
118118 keys = '<C-f>',
119119 command = function()
123123 }
125125 map.normal {
126 name = 'Scroll down in documentation popup',
126 description = 'Scroll down in documentation popup',
127127 category = 'ui',
128128 keys = '<C-b>',
129129 command = function()
158158 }
159159 end,
160160 },
161}
161}No final newline

neovim/lua/bugabinga/plugins/oil.lua

Modified

+3 / −3 text lines

1local map = require'std.keymap'
1local map = require'std.map'
33return {
44 'stevearc/oil.nvim',
3636 }
3838 map.normal {
39 name = 'Open parent directory in buffer.',
39 description = 'Open parent directory in buffer.',
4040 category = 'files',
4141 keys = '-',
4242 command = oil.open,
4343 -- command = oil.open_float,
4444 }
4545 end,
46}
46}No final newline

neovim/lua/bugabinga/plugins/persistence.lua

Modified

+4 / −4 text lines

1local map = require'std.keymap'
1local map = require'std.map'
33return {
44 'folke/persistence.nvim',
99 persistence.setup(opts)
1111 map.normal {
12 name = 'Restore session for current directory',
12 description = 'Restore session for current directory',
1313 category = 'history',
1414 keys = '<F4>',
1515 command = function() persistence.load() end,
1616 }
1818 map.normal {
19 name = 'Restore last session',
19 description = 'Restore last session',
2020 category = 'history',
2121 keys = '<F4><F4>',
2222 command = function() persistence.load{last= true} end,
2323 }
2525 end,
26}
26}No final newline

neovim/lua/bugabinga/plugins/specs.lua

Modified

+4 / −4 text lines

1local map = require'std.keymap'
1local map = require'std.map'
22local ignored = require'std.ignored'
44return {{
2424 }
2626 map.normal {
27 name = 'Find cursor!',
27 description = 'Find cursor!',
2828 category = 'fun',
2929 keys = '<leader><leader>',
3030 command = specs.show_specs,
3131 }
3333 map.normal {
34 name = 'Find cursor, for real!',
34 description = 'Find cursor, for real!',
3535 category = 'fun',
3636 keys = '<leader><leader><leader>',
3737 command = function()
3939 end,
4040 }
4141 end,
42}}
42}}No final newline

neovim/lua/bugabinga/plugins/spectre.lua

Modified

+9 / −5 text lines

1require'bugabinga.health'.add_dependency
1require 'bugabinga.health'.add_dependency
22{
33 name_of_executable = 'rg'
44}
1212 },
1313 opts = {
1414 live_update = true,
15 line_sep_start = '▛▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔',
16 result_padding = '▎',
17 line_sep = '▙▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁',
18 default = { replace = { cmd = 'oxi' } }
15 default = { replace = { cmd = 'oxi' } },
16 mapping = {
17 ['run_current_replace'] = {
18 map = '<leader>r',
19 cmd = function () require 'spectre.actions'.run_current_replace() end,
20 desc = 'replace current line'
21 },
22 }
1923 },

neovim/lua/bugabinga/plugins/substitute.lua

Modified

+5 / −5 text lines

1local map = require'std.keymap'
1local map = require'std.map'
33return {{
44 "gbprod/substitute.nvim",
88 substitute.setup{}
1010 map.normal {
11 name = 'substitution motion',
11 description = 'substitution motion',
1212 category = 'editing',
1313 keys = 's',
1414 command = substitute.operator,
1515 }
1717 map.normal {
18 name = 'substitution of current line',
18 description = 'substitution of current line',
1919 category = 'editing',
2020 keys = 'ss',
2121 command = substitute.line,
2222 }
2424 map.normal {
25 name = 'substitution until end of line',
25 description = 'substitution until end of line',
2626 category = 'editing',
2727 keys = 'S',
2828 command = substitute.eol,
3535 command = substitute.visual,
3636 }
3737 end,
38}}
38}}No final newline

neovim/lua/bugabinga/plugins/telescope.lua

Modified

+44 / −24 text lines

1local map = require 'std.keymap'
1local map = require 'std.map'
33require 'bugabinga.health'.add_dependency
44{
55 name = 'ripgrep',
66 name_of_executable = 'rg'
77}
8 {
9 name = 'find-fd',
10 name_of_executable = 'fd'
11 }
8 {
9 name = 'find-fd',
10 name_of_executable = 'fd'
11 }
1313return {
1414 'nvim-telescope/telescope.nvim',
2222 'nvim-telescope/telescope-ui-select.nvim',
2323 'jvgrootveld/telescope-zoxide',
2424 },
25 config = function ()
25 config = function()
2626 local telescope = require 'telescope'
2727 local builtin = require 'telescope.builtin'
2828 local actions = require 'telescope.actions'
4242 height = 0.42,
4343 preview_cutoff = 124,
4444 },
45 file_ignore_patterns = {
46 ".git/",
47 ".cache",
48 "%.o",
49 "%.a",
50 "%.out",
51 "%.class",
52 "%.pdf",
53 "%.mkv",
54 "%.mp4",
55 "%.zip",
56 },
4557 mappings = {
4658 i = {
4759 ['<C-j>'] = actions.cycle_history_next,
4860 ['<C-k>'] = actions.cycle_history_prev,
4961 ['<C-n>'] = actions.move_selection_next,
5062 ['<C-p>'] = actions.move_selection_previous,
63 ['<C-s>'] = actions.file_split,
5164 },
5265 n = { q = actions.close },
5366 },
6578 telescope.load_extension 'zoxide'
6780 map.normal {
68 name = 'Switch to recently used foleders',
81 description = 'Switch to recently used folders',
6982 category = 'navigation',
7083 keys = '<c-z>',
7184 command = telescope.extensions.zoxide.list,
7285 }
7487 map.normal.visual.terminal {
75 name = 'Search help files',
88 description = 'Search help files',
7689 category = 'help',
7790 keys = '<F1>',
78 command = function () builtin.help_tags( dropdown ) end,
91 command = function() builtin.help_tags(dropdown) end,
7992 }
8194 map.normal {
82 name = 'Open search for commands...',
95 description = 'Open search for commands...',
8396 category = 'plugins',
8497 keys = '<C-p>',
85 command = function () builtin.commands() end,
98 command = function() builtin.commands() end,
8699 }
88101 map.normal {
89 name = 'Open search for all files...',
102 description = 'Open search for all files...',
90103 category = 'search',
91104 keys = '<C-p><C-p>',
92 command = function () builtin.find_files( ivy ) end,
105 command = function() builtin.find_files(ivy) end,
93106 }
95108 map.normal {
96 name = 'Open search for keymaps...',
109 description = 'Open search for all recent files...',
110 category = 'search',
111 keys = '<C-p><C-o>',
112 command = function() builtin.oldfiles(ivy) end,
113 }
115 map.normal {
116 description = 'Open search for keymaps...',
97117 category = 'search',
98118 keys = '<C-p><C-k>',
99 command = function () builtin.keymaps( dropdown ) end,
119 command = function() builtin.keymaps(dropdown) end,
100120 }
102122 map.normal {
103 name = 'Open search for symbols...',
123 description = 'Open search for symbols...',
104124 category = 'search',
105125 keys = '<C-p><C-s>',
106 command = function () builtin.symbols( cursor ) end,
126 command = function() builtin.symbols(cursor) end,
107127 }
109129 map.normal {
110 name = 'Open search for all file contents...',
130 description = 'Open search for all file contents...',
111131 category = 'search',
112132 keys = '<C-p><C-g>',
113 command = function () builtin.live_grep( ivy ) end,
133 command = function() builtin.live_grep(ivy) end,
114134 }
116136 map.normal {
117 name = 'Open search for current buffer content...',
137 description = 'Open search for current buffer content...',
118138 category = 'search',
119139 keys = '<C-p><C-b>',
120 command = function () builtin.current_buffer_fuzzy_find( ivy ) end,
140 command = function() builtin.current_buffer_fuzzy_find(ivy) end,
121141 }
123143 map.normal {
124 name = 'Open search for buffers...',
144 description = 'Open search for buffers...',
125145 category = 'search',
126146 keys = '<C-e>',
127 command = function () builtin.buffers( cursor ) end,
147 command = function() builtin.buffers(cursor) end,
128148 }
129149 end,
130}
150}No final newline

neovim/lua/bugabinga/plugins/toggleterm.lua

Modified

+6 / −6 text lines

1local map = require 'std.keymap'
1local map = require 'std.map'
22local auto = require 'std.auto'
44require 'bugabinga.health'.add_dependency
5050 local set_terminal_keymaps = function ()
5151 local local_to_buffer = { buffer = 0 }
5252 map.terminal {
53 name = 'Quit insert mode',
53 description = 'Quit insert mode',
5454 category = 'terminal',
5555 keys = '<esc>',
5656 options = local_to_buffer,
6666 }
6868 map.normal {
69 name = 'Open vertical Terminal',
69 description = 'Open vertical Terminal',
7070 category = 'terminal',
7171 keys = '<F8>',
7272 command = '<CMD>exe v:count1 . "ToggleTerm size=60 direction=vertical"<CR>'
7373 }
7575 map.normal {
76 name = 'Open horizontal Terminal',
76 description = 'Open horizontal Terminal',
7777 category = 'terminal',
7878 keys = '<F9>',
7979 command = '<CMD>exe v:count1 . "ToggleTerm size=20 direction=horizontal"<CR>'
9393 _G.Gitui = function () gitui:toggle() end
9595 map.normal.terminal.insert {
96 name = 'Toggle gitui terminal in tab',
96 description = 'Toggle gitui terminal in tab',
9797 category = 'terminal',
9898 keys = '<F10>',
9999 command = Gitui,
139139 vim.cmd [[ command! Graphviz lua Graphviz() ]]
140140 end
141}
141}No final newline

neovim/lua/bugabinga/plugins/treesitter.lua

Modified

+215 / −134 text lines

1local map = require 'std.keymap'
2local auto = require 'std.auto'
3local want = require 'std.want'
1local map = require 'std.map'
5require'bugabinga.health'.add_dependency
3require 'bugabinga.health'.add_dependency
64{
7 name = 'CMake',
8 name_of_executable = 'cmake'
9}
10{
11 name_of_executable = 'make'
12}
13{
14 name_of_executable = 'zig'
15}
16{
17 name = 'TreeSitter CLI',
18 name_of_executable = 'tree-sitter'
19}
20{
21 name_of_executable = 'tar'
5 name = 'CMake',
6 name_of_executable = 'cmake'
227}
8 {
9 name_of_executable = 'make'
10 }
11 {
12 name_of_executable = 'zig'
13 }
14 {
15 name = 'TreeSitter CLI',
16 name_of_executable = 'tree-sitter'
17 }
18 {
19 name_of_executable = 'tar'
20 }
2422return {
25 'nvim-treesitter/nvim-treesitter',
26 branch = "master",
27 event = "BufRead",
28 cmd = {
29 "TSBufDisable",
30 "TSBufEnable",
31 "TSBufToggle",
32 "TSDisable",
33 "TSEnable",
34 "TSToggle",
35 "TSInstall",
36 "TSInstallInfo",
37 "TSInstallSync",
38 "TSModuleInfo",
39 "TSUninstall",
40 "TSUpdate",
41 "TSUpdateSync",
42 'TSPlaygroundToggle',
43 'TSHighlightCapturesUnderCursor',
44 'TSNodeUnderCursor',
45 },
46 build = function()
47 require'nvim-treesitter.install'.update{ with_sync = true }
48 end,
49 dependencies = {
50 "JoosepAlviste/nvim-ts-context-commentstring",
51 "windwp/nvim-ts-autotag",
52 'nvim-treesitter/playground',
53 'ThePrimeagen/refactoring.nvim',
54 },
55 config = function()
56 local install = require'nvim-treesitter.install'
57 local configs = require'nvim-treesitter.configs'
58 local parsers = require'nvim-treesitter.parsers'
23 'nvim-treesitter/nvim-treesitter',
24 branch = 'master',
25 event = 'BufRead',
26 cmd = {
27 'TSBufDisable',
28 'TSBufEnable',
29 'TSBufToggle',
30 'TSDisable',
31 'TSEnable',
32 'TSToggle',
33 'TSInstall',
34 'TSInstallInfo',
35 'TSInstallSync',
36 'TSModuleInfo',
37 'TSUninstall',
38 'TSUpdate',
39 'TSUpdateSync',
40 'TSPlaygroundToggle',
41 'TSHighlightCapturesUnderCursor',
42 'TSNodeUnderCursor',
43 },
44 build = function ()
45 require 'nvim-treesitter.install'.update { with_sync = true }
46 end,
47 dependencies = {
48 'JoosepAlviste/nvim-ts-context-commentstring',
49 'windwp/nvim-ts-autotag',
50 'nvim-treesitter/playground',
51 'nvim-treesitter/nvim-treesitter-textobjects',
52 },
53 config = function ()
54 local install = require 'nvim-treesitter.install'
55 local configs = require 'nvim-treesitter.configs'
56 local parsers = require 'nvim-treesitter.parsers'
60 install.prefer_git = false
61 install.compilers = { 'zig', 'clang', 'gcc', 'cl', 'cc', vim.fn.getenv 'CC' }
58 install.prefer_git = false
59 install.compilers = { 'zig', 'clang', 'gcc', 'cl', 'cc', vim.fn.getenv 'CC' }
63 configs.setup {
61 ---@diagnostic disable-next-line: missing-fields
62 configs.setup {
65 ensure_installed = {
66 'bash',
67 "c",
68 'comment',
69 'diff',
70 'dot',
71 'git_config',
72 'gitcommit',
73 'gitignore',
74 'java',
75 'jsonc',
76 'markdown',
77 'markdown_inline',
78 "lua",
79 'luap',
80 'luadoc',
81 'regex',
82 "vim",
83 "vimdoc",
84 "query",
85 'zig',
86 },
64 sync_install = false,
88 ignore_install = { 'oil' },
66 ensure_installed = {
67 'bash',
68 'c',
69 -- https://github.com/nvim-treesitter/nvim-treesitter/issues/5389
70 -- 'comment',
71 'diff',
72 'dot',
73 'git_config',
74 'gitcommit',
75 'gitignore',
76 'java',
77 'jsonc',
78 'markdown',
79 'markdown_inline',
80 'lua',
81 'luap',
82 'luadoc',
83 'regex',
84 'vim',
85 'vimdoc',
86 'query',
87 'zig',
88 },
90 auto_install = true,
90 ignore_install = { 'oil' },
92 autotag = { enable = true },
92 auto_install = true,
94 -- TODO: configure this
95 refactor = 'all',
94 autotag = { enable = true },
97 context_commentstring = { enable = true, enable_autocmd = false },
96 context_commentstring = { enable = true, enable_autocmd = false },
99 highlight = {
100 enable = true,
101 disable = function(lang, buf)
102 local max_filesize = 1000 * 1024 -- 1000 KiB
103 local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
104 if ok and stats and stats.size > max_filesize then
105 return true
106 end
107 end,
108 additional_vim_regex_highlighting = false,
109 },
98 highlight = {
99 enable = true,
100 disable = function ( _, buf )
101 local max_filesize = 1000 * 1024 -- 1000 KiB
102 local ok, stats = pcall( vim.loop.fs_stat, vim.api.nvim_buf_get_name( buf ) )
103 if ok and stats and stats.size > max_filesize then
104 return true
105 end
106 end,
107 additional_vim_regex_highlighting = false,
108 },
111 incremental_selection = {
112 enable = true,
113 keymaps = {
114 init_selection = "<up>",
115 node_incremental = "<right>",
116 node_decremental = "<left>",
117 scope_incremental = false,
118 },
119 },
110 incremental_selection = {
111 enable = true,
112 keymaps = {
113 init_selection = '<up>',
114 node_incremental = '<right>',
115 node_decremental = '<left>',
116 scope_incremental = false,
117 },
118 },
121 indent = { enable = true },
120 indent = { enable = true },
123 playground = {
124 enable = true,
125 disable = {},
126 updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
127 persist_queries = false, -- Whether the query persists across vim sessions
128 keybindings = {
129 toggle_query_editor = 'o',
130 toggle_hl_groups = 'i',
131 toggle_injected_languages = 't',
132 toggle_anonymous_nodes = 'a',
133 toggle_language_display = 'I',
134 focus_language = 'f',
135 unfocus_language = 'F',
136 update = 'R',
137 goto_node = '<cr>',
138 show_help = '?',
139 },
140 },
141 }
122 playground = {
123 enable = true,
124 disable = {},
125 updatetime = 25,
126 persist_queries = false,
127 keybindings = {
128 toggle_query_editor = 'o',
129 toggle_hl_groups = 'i',
130 toggle_injected_languages = 't',
131 toggle_anonymous_nodes = 'a',
132 toggle_language_display = 'I',
133 focus_language = 'f',
134 unfocus_language = 'F',
135 update = 'R',
136 goto_node = '<cr>',
137 show_help = '?',
138 },
139 },
143 parsers.get_parser_configs().just = {
144 install_info = {
145 url = 'https://github.com/IndianBoy42/tree-sitter-just', -- local path or git repo
146 files = { 'src/parser.c', 'src/scanner.cc' },
147 branch = 'main',
148 },
149 maintainers = { '@IndianBoy42' },
150 }
151 end,
152}
141 textobjects = {
142 select = {
143 enable = true,
144 lookahead = true,
145 keymaps = {
146 ['af'] = '@function.outer',
147 ['if'] = '@function.inner',
149 ['ac'] = '@class.outer',
150 ['ic'] = '@class.inner',
152 ['at'] = '@comment.outer',
153 ['it'] = '@comment.inner',
155 ['as'] = { query = '@scope', query_group = 'locals', desc = 'Select language scope' },
156 },
157 selection_modes = {
158 ['@parameter.outer'] = 'v', -- charwise
159 ['@function.outer'] = 'V', -- linewise
160 ['@class.outer'] = '<c-v>', -- blockwise
161 ['@scope'] = 'V',
162 },
163 include_surroundig_whitespace = true,
164 },
166 swap = {
167 enable = true,
168 swap_next = {
169 ['<leader>sn'] = '@parameter.inner',
170 },
171 swap_previous = {
172 ['<leader>sp'] = '@parameter.inner',
173 },
174 },
176 lsp_interop = {
177 enable = true,
178 border = vim.g.border_style,
179 floating_preview_opts = {},
180 peek_definition_code = {
181 ['<c-)>'] = '@function.outer',
182 ['<c-a-)>'] = '@class.outer',
183 },
184 },
186 move = {
187 enable = true,
188 set_jumps = true,
189 goto_next = {
190 [']f'] = '@function.outer',
191 [']c'] = { query = '@class.outer', desc = 'Next class start' },
192 [']s'] = { query = '@scope', query_group = 'locals', desc = 'Next scope' },
193 [']i'] = '@conditional.outer',
194 [']a'] = '@parameter.outer',
195 },
196 goto_previous = {
197 ['[f'] = '@function.outer',
198 ['[c'] = { query = '@class.outer', desc = 'Previous class start' },
199 ['[s'] = { query = '@scope', query_group = 'locals', desc = 'Previous scope' },
200 ['[i'] = '@conditional.outer',
201 ['[a'] = '@parameter.outer',
202 }
203 },
204 }
205 }
207 local ts_repeat_move = require 'nvim-treesitter.textobjects.repeatable_move'
209 map.normal.visual.operator_pending {
210 description = 'This repeats the last query with always previous direction and to the start of the range.',
211 keys = '<PageUp>',
212 category = 'textobjects',
213 command = function () ts_repeat_move.repeat_last_move { forward = false } end
214 }
216 map.normal.visual.operator_pending {
217 description = 'This repeats the last query with always next direction and to the end of the range.',
218 keys = '<PageDown>',
219 category = 'textobjects',
220 command = function () ts_repeat_move.repeat_last_move { forward = true } end
221 }
223 ---@diagnostic disable-next-line: inject-field
224 parsers.get_parser_configs().just = {
225 install_info = {
226 url = 'https://github.com/IndianBoy42/tree-sitter-just', -- local path or git repo
227 files = { 'src/parser.c', 'src/scanner.cc' },
228 branch = 'main',
229 },
230 maintainers = { '@IndianBoy42' },
231 }
232 end,
233}No final newline

neovim/lua/bugabinga/plugins/treesj.lua

Modified

+3 / −3 text lines

1local map = require'std.keymap'
1local map = require'std.map'
33return {
44 'Wansmer/treesj',
1212 }
1414 map.normal {
15 name = 'Toggle Tree Join/Split',
15 description = 'Toggle Tree Join/Split',
1616 category = 'editing',
1717 keys = '<C-j>',
1818 command = treesj.toggle,
1919 }
2020 end,
21}
21}No final newline

neovim/lua/bugabinga/plugins/whichkey.lua

Added
new file mode 100644

+27 / −0 text lines

1local ignored = require 'std.ignored'
2
3--TODO: add which-key highlights in nugu
4return {
5 'folke/which-key.nvim',
6 event = 'VeryLazy',
7 init = function ()
8 vim.o.timeout = true
9 vim.o.timeoutlen = 300
10 end,
11 opts = {
12 operators = {
13 -- TODO: make surround bind more logical and add here
14 ms = 'Surround',
15 },
16 icons = {
17 group = ' '
18 },
19 window = {
20 border = vim.g.border_style,
21 winblend = 42/2,
22 },
23 disable = {
24 buftypes = ignored.buftypes,
25 }
26 }
27}

neovim/lua/std/ignored.lua

Modified

+1 / −0 text lines

1212 'lazy',
1313 'oil',
1414 'spectre_panel',
15 'WhichKey',
1718local buftypes = {

neovim/lua/std/keymap.lua

Deleted
deleted file mode 100644

+0 / −79 text lines

1local available_modes = {
2 normal_visual_select_operator_pending = '',
3
4 normal = 'n',
5 n = 'n',
6
7 insert = 'i',
8 i = 'i',
9
10 visual = 'x',
11 x = 'x',
13 visual_select = 'v',
14 v = 'v',
16 select = 's',
17 s = 's',
19 operator_pending = 'o',
20 o = 'o',
22 ['!'] = '!',
23 insert_command_line = '!',
25 command_line = 'c',
26 c = 'c',
28 terminal = 't',
29 t = 't',
30}
32local bind = function(self, map)
33 vim.validate{
34 map = { map, 'table' },
35 keys = { map.keys, 'string' },
36 command = { map.command, { 'function', 'string' }},
37 }
39 local keys = map.keys
40 local command = map.command
42 map.options = map.options or {}
44 if map.category and map.description then
45 map.description = map.category .. ': ' .. map.description
46 end
48 local options = vim.tbl_extend('keep', map.options, {
49 silent = true,
50 desc = map.description,
51 })
53 if vim.tbl_isempty(self.mode) then self.mode[1] = available_modes.normal_visual_select_operator_pending end
54 vim.keymap.set(self.mode, keys, command, options)
55 self.mode = {}
57 return function()
58 local delete_options = options.buffer and { buffer = options.buffer } or {}
59 vim.keymap.del(self.mode, keys, delete_options)
60 end
61end
63local add_mode = function(self, key)
64 local new_mode = available_modes[key]
65 if new_mode == nil then error('unknown keymap mode requested: ' .. key) end
66 if not self.mode[new_mode] then
67 table.insert(self.mode, new_mode)
68 end
69 return self
70end
72return setmetatable(
73{
74 mode = {},
75},
76{
77 __index = add_mode,
78 __call = bind,
79})

neovim/lua/std/map.lua

Added
new file mode 100644

+79 / −0 text lines

1local available_modes = {
2 normal_visual_select_operator_pending = '',
3
4 normal = 'n',
5 n = 'n',
6
7 insert = 'i',
8 i = 'i',
9
10 visual = 'x',
11 x = 'x',
13 visual_select = 'v',
14 v = 'v',
16 select = 's',
17 s = 's',
19 operator_pending = 'o',
20 o = 'o',
22 ['!'] = '!',
23 insert_command_line = '!',
25 command_line = 'c',
26 c = 'c',
28 terminal = 't',
29 t = 't',
30}
32local bind = function ( self, map )
33 vim.validate {
34 map = { map, 'table' },
35 ['map.keys'] = { map.keys, 'string' },
36 ['map.command'] = { map.command, { 'function', 'string' } },
37 }
39 local keys = map.keys
40 local command = map.command
42 map.options = map.options or {}
44 if map.category and map.description then
45 map.description = map.category .. ': ' .. map.description
46 end
48 local options = vim.tbl_extend( 'keep', map.options, {
49 silent = true,
50 desc = map.description,
51 } )
53 if vim.tbl_isempty( self.mode ) then self.mode[1] = available_modes.normal_visual_select_operator_pending end
54 vim.keymap.set( self.mode, keys, command, options )
55 self.mode = {}
57 return function ()
58 local delete_options = options.buffer and { buffer = options.buffer } or {}
59 vim.keymap.del( self.mode, keys, delete_options )
60 end
61end
63local add_mode = function ( self, key )
64 local new_mode = available_modes[key]
65 if new_mode == nil then error( 'unknown keymap mode requested: ' .. key ) end
66 if not self.mode[new_mode] then
67 table.insert( self.mode, new_mode )
68 end
69 return self
70end
72return setmetatable(
73 {
74 mode = {},
75 },
76 {
77 __index = add_mode,
78 __call = bind,
79 } )

neovim/lua/std/project.lua

Modified

+48 / −49 text lines

1local ignored = require'std.ignored'
2local table = require'std.table'
1local ignored = require 'std.ignored'
2local table = require 'std.table'
33local join = table.join
44local dirname = vim.fs.dirname
55local normalize = vim.fs.normalize
6868---directory is used.
6969---@return string? # Directory, that contains the `markers` and lies on the path from `path` to `stop`.
7070local function find_root(path, markers, stop)
72 validate{
73 path = { path, 'string', true },
74 markers = { markers, 'table'},
75 stop = { stop, 'string', true},
76 }
71 validate {
72 path = { path, 'string', true },
73 markers = { markers, 'table' },
74 stop = { stop, 'string', true },
75 }
7877 path = path or dirname(vim.api.nvim_buf_get_name(0))
7978 path = normalize(path)
8079 stop = stop or vim.uv.os_homedir()
8180 stop = normalize(stop)
83 if not exists(stop) then error( ( 'the stop directory %s does not exist!' ):format(stop) ) end
82 if not exists(stop) then error(('the stop directory %s does not exist!'):format(stop)) end
8584 local cache_hit = cache_get(path, markers)
8685 if cache_hit then
10099 local current_path = path
101100 while current_path ~= stop do
102101 if loop_count > MAX_TRAVERSAL_COUNT then
103 vim.notify(( 'searching for markers reached the max traversal count for path %s !' ):format(path))
102 vim.notify(('searching for markers reached the max traversal count for path %s !'):format(path))
104103 break
105104 end
132131 local project_root = nil
133132 local max_likelyhood = 0
134133 -- the project root is most likely the directory with the highest marker count
135 -- and distance to current buffer.
134 -- and lowest distance to current buffer.
136135 -- because if there are markers further away from the buffer than other markers,
137136 -- then it is most likely a nested project structure (multi-module).
138137 -- in those cases we are looking for the root project folder, instead the nearest
139138 -- child project root folder.
140139 for _, score in ipairs(directory_scores) do
141 local likelihood = score.marker_count + score.distance_to_buffer_file
140 local likelihood = score.marker_count + 1/score.distance_to_buffer_file
142141 if likelihood > max_likelyhood then
143142 max_likelyhood = likelihood
144143 project_root = score.path
159158local function find_project_root(path, markers)
160159 -- define some language-independent markers
161160 local default_markers = {
162 { name = '.git', weight = 1 },
163 { name = '.gitignore', weight = 1 },
164 { name = '.svn', weight = 1 },
165 { name = 'justfile', weight = 1 },
166 { name = 'Jenkinsfile', weight = 1 },
161 { name = '.git', weight = 1 },
162 { name = '.gitignore', weight = 1 },
163 { name = '.svn', weight = 1 },
164 { name = 'justfile', weight = 1 },
165 { name = 'Jenkinsfile', weight = 1 },
167166 { name = '.editorconfig', weight = 1 },
168 { name = 'LICENSE', weight = 1 },
169 { name = 'LICENSE.md', weight = 1 },
170 { name = 'LICENSE.txt', weight = 1 },
171 { name = 'COPYING', weight = 1 },
172 { name = 'README', weight = 1 },
173 { name = 'README.md', weight = 1 },
174 { name = 'Makefile', weight = 1 },
175 { name = 'flake.nix', weight = 1 },
176 { name = 'flake.nix', weight = 1 },
167 { name = 'LICENSE', weight = 1 },
168 { name = 'LICENSE.md', weight = 1 },
169 { name = 'LICENSE.txt', weight = 1 },
170 { name = 'COPYING', weight = 1 },
171 { name = 'README', weight = 1 },
172 { name = 'README.md', weight = 1 },
173 { name = 'Makefile', weight = 1 },
174 { name = 'flake.nix', weight = 1 },
175 { name = 'flake.nix', weight = 1 },
177176 }
179178 return find_root(path, join(default_markers, markers))
186185local function find_java_project_root(path)
187186 local java_markers = {
188 { name = '.idea', weight = 2 },
189 { name = '.classpath', weight = 2 },
190 { name = '.settings', weight = 2 },
191 { name = '.project', weight = 2 },
192 { name = 'target', weight = 2 },
193 { name = 'pom.xml', weight = 2 },
194 { name = 'mvnw', weight = 3 },
195 { name = '.mvn', weight = 3 },
196 { name = 'mvnw.cmd', weight = 3 },
197 { name = 'build.gradle', weight = 2 },
187 { name = '.idea', weight = 2 },
188 { name = '.classpath', weight = 2 },
189 { name = '.settings', weight = 2 },
190 { name = '.project', weight = 2 },
191 { name = 'target', weight = 2 },
192 { name = 'pom.xml', weight = 2 },
193 { name = 'mvnw', weight = 3 },
194 { name = '.mvn', weight = 3 },
195 { name = 'mvnw.cmd', weight = 3 },
196 { name = 'build.gradle', weight = 2 },
198197 { name = 'gradle.properties', weight = 3 },
199 { name = 'settings.gradle', weight = 3 },
200 { name = 'gradlew', weight = 3 },
201 { name = 'gradlew.bat', weight = 3 },
198 { name = 'settings.gradle', weight = 3 },
199 { name = 'gradlew', weight = 3 },
200 { name = 'gradlew.bat', weight = 3 },
202201 }
203202 return find_root(path, java_markers)
204203end
206205-- TODO: how to get a marker for luarocks stuff?
207206local lua_markers = {
208 { name = '.luarc.json', weight = 1 },
207 { name = '.luarc.json', weight = 1 },
209208 { name = '.luarc.jsonc', weight = 1 },
210 { name = '.luacheckrc', weight = 1 },
209 { name = '.luacheckrc', weight = 1 },
211210 { name = '.stylua.toml', weight = 1 },
212 { name = 'stylua.toml', weight = 1 },
213 { name = 'selene.toml', weight = 1 },
214 { name = 'selene.yml', weight = 1 },
211 { name = 'stylua.toml', weight = 1 },
212 { name = 'selene.toml', weight = 1 },
213 { name = 'selene.yml', weight = 1 },
217216local nvim_lua_markers = {
218 {name = 'neovim.yml', weight = 1},
219 {name = 'lua', weight = 1},
217 { name = 'neovim.yml', weight = 1 },
218 { name = 'lua', weight = 1 },
222221local find_lua_project_root = function(path)
228227end
230229local zig_markers = {
231 { name = 'build.zig', weight = 3 },
230 { name = 'build.zig', weight = 3 },
232231 { name = 'zls.build.json', weight = 3 },
233 { name = 'zig-cache', weight = 1 },
234 { name = 'zig-out', weight = 1 },
232 { name = 'zig-cache', weight = 1 },
233 { name = 'zig-out', weight = 1 },
237236local find_zig_project_root = function(path)

neovim/lua/std/want.lua

Modified

+15 / −13 text lines

11--- attempts to import modules with the given names.
2---@param module_names table name or list of names, or a function that returns those
2---@param module_names string|table name or list of names, or a function that returns those
33---@return function function that takes a function that takes in the modules listed by `module_names`
4return function(module_names)
5 return function(block, error_handler)
4return function ( module_names )
5 return function ( block, error_handler )
66 local loaded_modules = {}
77 local failed_modules = {}
8 if type(module_names) == "string" then
8 if type( module_names ) == 'string' then
99 module_names = { module_names }
1010 end
11 for _, name in pairs(module_names) do
12 local status_ok, module = pcall(require, name)
11 for _, name in pairs( module_names ) do
12 local status_ok, module = pcall( require, name )
1313 if status_ok then
14 table.insert(loaded_modules, module)
14 table.insert( loaded_modules, module )
1515 else
16 table.insert(failed_modules, module)
16 table.insert( failed_modules, module )
1717 end
1818 end
19 for _, module in pairs(failed_modules) do
20 vim.notify('A wanted module failed to load: ' .. module, 'error')
21 end
2219 if #failed_modules > 0 then
23 return error_handler and error_handler(unpack(failed_modules))
20 return error_handler and type( error_handler ) == 'function' and error_handler( unpack( failed_modules ) ) or
21 error_handler
22 else
23 for _, module in pairs( failed_modules ) do
24 vim.notify( 'A wanted module failed to load: ' .. module, 'error' )
25 end
2426 end
25 return block and block(unpack(loaded_modules))
27 return block and block( unpack( loaded_modules ) )
2628 end
2729end

nushell/env.nu

Modified

+13 / −2 text lines

11# GLOBAL VARIABLES
2# GLOBAL VARIABLES
34$env.WIN32 = ( $nu.os-info.name =~ "windows" )
45$env.NURC_DIR = ( $nu.config-path | path expand | path dirname )
1112$env.PATH = ($env.PATH | prepend ( if $env.WIN32 { [] } else { [ $"($env.WORKSPACE)/tools", $"($env.HOME)/.cargo/bin" ] } ))
1314# theme for ls and other programs, that use LS_COLORS
14# $env.LS_COLORS = ( try { vivid generate nord } catch { "" } )
15$env.LS_COLORS = (try { vivid generate ayu | into string } catch {""})
1617# Specifies how environment variables are:
1718# - converted from a string to a value on Nushell startup (from_string)
3233$env.NU_LIB_DIRS = [
3334 ($nu.config-path | path dirname | path join 'modules'),
3435 ($nu.config-path | path dirname | path join 'completions')
35]No final newline
36]
38alias cb = flatpak run app.getclipboard.Clipboard
40$env.CLIPBOARD_EDITOR = nvim
41$env.CLIPBOARD_HISTORY = 100000
42$env.CLIPBOARD_PERSISTDIR = /home/oli/Clipboard
43$env.CLIPBOARD_NOAUDIO = 1
44# $env.CLIPBOARD_NOGUI = 1
45$env.CLIPBOARD_THEME = light

nushell/modules/aliases.nu

Modified

+1 / −1 text lines

11# Semantic aliases
22export alias show = bat
33export def list [] { ls --all --long --du --mime-type | where type == dir | append (ls --all --long --du --mime-type | where type != dir) }
4export alias browse = firefox
4export alias web = firefox
55export alias edit = hx
66# TODO ewrite bak command
77export alias backup = bak

tools/install_wezterm_terminfo.sh

Modified + mode changed
old mode 100644 new mode 100755

+3 / −3 text lines

11tempfile=$(mktemp) \
2 && curl -o $tempfile https://raw.githubusercontent.com/wez/wezterm/main/termwiz/data/wezterm.terminfo \
3 && tic -x -o ~/.terminfo $tempfile \
4 && rm $tempfile
2 && curl -o "$tempfile" https://raw.githubusercontent.com/wez/wezterm/main/termwiz/data/wezterm.terminfo \
3 && tic -x -o ~/.terminfo "$tempfile" \
4 && rm "$tempfile"