repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim: gomove keybinds

6a53d82b42be07dacbf662b759158fe1ccac0d75

Oliver Jan Krylow <olver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (12)

neovim/ftplugin/markdown.lua

Modified
7 7 -- local auto = require 'bugabinga.std.auto'
8 8 local map = require 'bugabinga.std.keymap'
10 -want { 'toggleterm.terminal' } (function(toggleterm)
11 - local Terminal = toggleterm.Terminal
12 - local file = vim.api.nvim_buf_get_name(0)
13 - local markdown_preview_command = 'mdcat ' .. file
14 - -- this command only shows the correct preview, if the buffer has been saved
15 - -- before. i could not figure out how to use the buffer content instead.
16 - local mdcat = Terminal:new {
17 - cmd = markdown_preview_command,
18 - direction = 'float',
19 - start_in_insert = false,
20 - close_on_exit = false,
21 - hidden = true,
22 - }
23 - map {
24 - description = 'Opens a preview of the current markdown buffer.',
25 - category = map.CATEGORY.MARKDOWN,
26 - mode = map.MODE.NORMAL,
27 - keys = '<LEADER>mp',
28 - command = function()
29 - mdcat:toggle()
30 - end,
31 - }
10 +want { 'toggleterm.terminal' }(function(toggleterm)
11 + local Terminal = toggleterm.Terminal
12 + local file = vim.api.nvim_buf_get_name(0)
13 + local markdown_preview_command = 'mdcat ' .. file
14 + -- this command only shows the correct preview, if the buffer has been saved
15 + -- before. i could not figure out how to use the buffer content instead.
16 + local mdcat = Terminal:new {
17 + cmd = markdown_preview_command,
18 + direction = 'float',
19 + start_in_insert = false,
20 + close_on_exit = false,
21 + hidden = true,
22 + }
23 + map {
24 + description = 'Opens a preview of the current markdown buffer.',
25 + category = map.CATEGORY.MARKDOWN,
26 + mode = map.MODE.NORMAL,
27 + keys = '<LEADER>mp',
28 + command = function()
29 + mdcat:toggle()
30 + end,
31 + }
32 32 end)

neovim/init.lua

Modified
66 66 -- TODO:
67 67 -- [ ] DAP
68 +-- [ ] put all keybinds into facade
68 69 -- [ ] preview multimedia with telescope
69 70 -- [ ] icon facade: icon.get("name")
70 --- [ ] make keymap facade immediate and support buffer local binds
71 --- [ ] put all keybinds into facade
72 71 -- [ ] use nvim-specific lsp only in neovim config
72 +-- [ ] stop treesitter error highlight while typing
73 73 -- [ ] fix gitsigns highights
74 74 -- [ ] hydra cycle buffers
75 75 -- [ ] add fstabfmt to null-ls
76 --- [ ] add keybind to dismiss notify window
77 --- [ ] start a toggleterm with: watch <buffer> { clear; mdcat <buffer> }
78 76 -- [ ] load plugins/init.lua and sync on write. reload init.lua?
79 --- [ ] disable gomove in special buffers
80 --- [ ] replace filetype.lua plugin with builtin: https://neovim.io/news/2022/04
81 77 -- [ ] lsp diagnostics hide in insert mode
82 --- [ ] change style for read only files
78 +-- [ ] cross platform status bar
79 +-- [ ] show winbar
80 +-- [ ] show read only files in winbar
83 81 -- [ ] make cursor red if diagnostics
84 82 -- [ ] toggle diagnostics keybind
83 +-- [~] start a toggleterm with: watch <buffer> { clear; mdcat <buffer> }
84 +-- [~] disable gomove in special buffers
85 +-- [x] replace filetype.lua plugin with builtin: https://neovim.io/news/2022/04
86 +-- [x] add keybind to dismiss notify window
87 +-- [x] make keymap facade immediate and support buffer local binds
85 88 -- [~] disable gomove in special buffers
86 89 -- [x] replace filetype.lua plugin with builtin: https://neovim.io/news/2022/04
87 90 -- [x] undofile not work?
124 127 -- https://github.com/ThePrimeagen/refactoring.nvim
125 128 -- https://github.com/windwp/windline.nvim
126 129 -- https://github.com/hrsh7th/nvim-pasta
127 --- https://github.com/VonHeikemen/project-settings.nvim
128 130 -- https://github.com/Saecki/crates.nvim
129 131 -- https://github.com/VonHeikemen/little-wonder
132 +-- https://github.com/VonHeikemen/project-settings.nvim
130 133 -- https://github.com/jinh0/eyeliner.nvim
131 134 -- https://github.com/iamcco/markdown-preview.nvim
132 135 -- https://github.com/jakewvincent/mkdnflow.nvim
133 136 -- https://github.com/rktjmp/lush.nvim
137 +-- https://github.com/jbyuki/venn.nvim

neovim/lua/bugabinga/fuzzy-search-ui.lua

Modified
1 -local map = require('bugabinga.std.keymap')
1 +local map = require 'bugabinga.std.keymap'
2 2 local want = require 'bugabinga.std.want'
3 3 want { 'telescope', 'command_center', 'dressing' }(function(telescope, command_center, dressing)
4 4 -- Command Center gets loaded here to configure it in the context of Telescope.

neovim/lua/bugabinga/lsp.lua

Modified
1 1 local want = require 'bugabinga.std.want'
2 2 want {
3 - 'lsp-zero',
4 - 'null-ls',
5 - 'nvim-lsp-installer',
6 - 'lua-dev',
7 - 'rust-tools',
8 - 'nvim-navic',
9 - 'lsp-status',
10 -} (function(zero, null_ls, installer, luadev, rust, navic, lsp_status)
11 - installer.settings {
12 - ui = {
13 - border = 'rounded',
14 - },
15 - }
3 + 'lsp-zero',
4 + 'null-ls',
5 + 'nvim-lsp-installer',
6 + 'lua-dev',
7 + 'rust-tools',
8 + 'nvim-navic',
9 + 'lsp-status',
10 +}(function(zero, null_ls, installer, luadev, rust, navic, lsp_status)
11 + installer.settings {
12 + ui = {
13 + border = 'rounded',
14 + },
15 + }
17 - zero.preset 'recommended'
17 + zero.preset 'recommended'
19 - -- setup lsp for my neovim config
20 - zero.nvim_workspace {
21 - -- add paths of all plugins and neovim
22 - library = vim.api.nvim_get_runtime_file('', true),
23 - }
24 - -- Initialize rust_analyzer with rust-tools
25 - rust.setup {
26 - server = zero.build_options('rust_analyzer', {}),
27 - }
19 + -- setup lsp for my neovim config
20 + zero.nvim_workspace {
21 + -- add paths of all plugins and neovim
22 + library = vim.api.nvim_get_runtime_file('', true),
23 + }
24 + -- Initialize rust_analyzer with rust-tools
25 + rust.setup {
26 + server = zero.build_options('rust_analyzer', {}),
27 + }
29 - -- this will prevent zero from loading this server.
30 - -- Java will be managed by nvim-jdtls, which wants to do things differently.
31 - -- see ftplugin/java.lua
32 - zero.build_options('jdtls', {})
29 + -- this will prevent zero from loading this server.
30 + -- Java will be managed by nvim-jdtls, which wants to do things differently.
31 + -- see ftplugin/java.lua
32 + zero.build_options('jdtls', {})
34 - -- lua neovim lsp
35 - luadev.setup {
36 - lspconfig = zero.defaults.nvim_workspace(),
37 - }
34 + -- lua neovim lsp
35 + luadev.setup {
36 + lspconfig = zero.defaults.nvim_workspace(),
37 + }
39 - -- disable disco mode while typing
40 - zero.setup_nvim_cmp {
41 - completion = {
42 - autocomplete = false,
43 - },
44 - }
39 + -- disable disco mode while typing
40 + zero.setup_nvim_cmp {
41 + completion = {
42 + autocomplete = false,
43 + },
44 + }
46 - -- Format on Save when any LSP supports it.
47 - local auto = require 'bugabinga.std.auto'
48 - local null_opts = zero.build_options('null-ls', {
49 - on_attach = function(client)
50 - if client.server_capabilities.documentFormattingProvider then
51 - auto 'format_buffer_on_write' {
52 - description = 'Format the current buffer before writing.',
53 - events = 'BufWritePre',
54 - pattern = '<buffer>',
55 - callback = function(context)
56 - vim.lsp.buf.format()
57 - vim.notify('Formatted ' .. context.file)
58 - end,
59 - }
60 - end
61 - end,
62 - })
46 + -- Format on Save when any LSP supports it.
47 + local auto = require 'bugabinga.std.auto'
48 + local null_opts = zero.build_options('null-ls', {
49 + on_attach = function(client)
50 + if client.server_capabilities.documentFormattingProvider then
51 + auto 'format_buffer_on_write' {
52 + description = 'Format the current buffer before writing.',
53 + events = 'BufWritePre',
54 + pattern = '<buffer>',
55 + callback = function(context)
56 + vim.lsp.buf.format()
57 + vim.notify('Formatted ' .. context.file)
58 + end,
59 + }
60 + end
61 + end,
62 + })
64 - local formatting = null_ls.builtins.formatting
65 - local diagnostics = null_ls.builtins.diagnostics
66 - local code_actions = null_ls.builtins.code_actions
67 - local hover = null_ls.builtins.hover
68 - local completion = null_ls.builtins.completion
64 + local formatting = null_ls.builtins.formatting
65 + local diagnostics = null_ls.builtins.diagnostics
66 + local code_actions = null_ls.builtins.code_actions
67 + local hover = null_ls.builtins.hover
68 + local completion = null_ls.builtins.completion
70 - -- run diagnostics on save
71 - local diagnostics_on_save = { method = null_ls.methods.DIAGNOSTICS_ON_SAVE }
72 - null_ls.setup {
73 - on_attach = null_opts.on_attach,
74 - sources = {
75 - formatting.black.with { extra_args = { '--fast' } },
76 - formatting.stylua,
77 - formatting.clang_format,
78 - formatting.codespell,
79 - formatting.jq,
80 - formatting.protolint,
81 - formatting.shellharden,
82 - formatting.shfmt,
83 - formatting.taplo,
70 + -- run diagnostics on save
71 + local diagnostics_on_save = { method = null_ls.methods.DIAGNOSTICS_ON_SAVE }
72 + null_ls.setup {
73 + on_attach = null_opts.on_attach,
74 + sources = {
75 + formatting.black.with { extra_args = { '--fast' } },
76 + formatting.stylua,
77 + formatting.clang_format,
78 + formatting.codespell,
79 + formatting.jq,
80 + formatting.protolint,
81 + formatting.shellharden,
82 + formatting.shfmt,
83 + formatting.taplo,
85 - hover.dictionary,
85 + hover.dictionary,
87 - diagnostics.actionlint.with(diagnostics_on_save),
88 - diagnostics.checkmake.with(diagnostics_on_save),
89 - diagnostics.codespell.with(diagnostics_on_save),
90 - diagnostics.editorconfig_checker.with(diagnostics_on_save).with { command = 'editorconfig-checker' },
91 - diagnostics.gitlint.with(diagnostics_on_save),
92 - diagnostics.protoc_gen_lint.with(diagnostics_on_save),
93 - diagnostics.protolint.with(diagnostics_on_save),
94 - diagnostics.selene.with(diagnostics_on_save).with {
95 - -- null-ls determines the root in a too simplistic manner.
96 - -- since my neovim configuration live inside my dotfiles, the dotfiles root
97 - -- was taken. but i want the neovim config folder as root.
98 - cwd = function(parameters)
99 - local project = require 'bugabinga.std.project'
100 - local root = project.determine_project_root({ name = 'selene.toml', weight = 10 }, parameters.root)
101 - return root or parameters.root
102 - end,
103 - },
104 - diagnostics.shellcheck.with(diagnostics_on_save),
105 - diagnostics.tidy.with(diagnostics_on_save),
87 + diagnostics.actionlint.with(diagnostics_on_save),
88 + diagnostics.checkmake.with(diagnostics_on_save),
89 + diagnostics.codespell.with(diagnostics_on_save),
90 + diagnostics.editorconfig_checker.with(diagnostics_on_save).with { command = 'editorconfig-checker' },
91 + diagnostics.gitlint.with(diagnostics_on_save),
92 + diagnostics.protoc_gen_lint.with(diagnostics_on_save),
93 + diagnostics.protolint.with(diagnostics_on_save),
94 + diagnostics.selene.with(diagnostics_on_save).with {
95 + -- null-ls determines the root in a too simplistic manner.
96 + -- since my neovim configuration live inside my dotfiles, the dotfiles root
97 + -- was taken. but i want the neovim config folder as root.
98 + cwd = function(parameters)
99 + local project = require 'bugabinga.std.project'
100 + local root = project.determine_project_root({ name = 'selene.toml', weight = 10 }, parameters.root)
101 + return root or parameters.root
102 + end,
103 + },
104 + diagnostics.shellcheck.with(diagnostics_on_save),
105 + diagnostics.tidy.with(diagnostics_on_save),
107 - code_actions.refactoring,
108 - code_actions.shellcheck,
107 + code_actions.refactoring,
108 + code_actions.shellcheck,
110 - completion.luasnip,
111 - },
112 - }
110 + completion.luasnip,
111 + },
114 - zero.on_attach(function(client, buffer_number)
115 - if client.name ~= 'null-ls' and not vim.b.lsp_attached then
116 - navic.attach(client, buffer_number)
117 - lsp_status.on_attach(client, buffer_number)
118 - end
119 - end)
114 + zero.on_attach(function(client, buffer_number)
115 + if client.name ~= 'null-ls' and not vim.b.lsp_attached then
116 + navic.attach(client, buffer_number)
117 + lsp_status.on_attach(client, buffer_number)
118 + end
119 + end)
121 - zero.setup()
121 + zero.setup()

neovim/lua/bugabinga/move-code.lua

Modified
1 1 local want = require 'bugabinga.std.want'
2 +local map = require 'bugabinga.std.keymap'
2 4 want { 'gomove' }(function(move)
3 5 move.setup {
4 - --FIXME: replace with keymap facade
5 6 -- whether or not to map default key bindings, (true/false)
6 - map_defaults = true,
7 + map_defaults = false,
7 8 -- whether or not to reindent lines moved vertically (true/false)
8 9 reindent = true,
9 10 -- whether or not to undojoin same direction moves (true/false)
11 12 -- whether to not to move past end column when moving blocks horizontally, (true/false)
12 13 move_past_end_col = false,
16 + -- default mappings in gomove set no options, but use old keymap api.
17 + -- recreating old defaults here:
18 + local options = { remap = true }
20 + -- i have tried using the lua functions directly for the commands below.
21 + -- the behaviour was slightly buggy in respects to block selections though.
22 + -- unsure why that is.
24 + -- NORMAL MOVE
25 + map {
26 + description = 'Move character left',
27 + category = map.CATEGORY.EDITING,
28 + command = '<Plug>GoNSMLeft',
29 + mode = map.MODE.NORMAL,
30 + keys = map.KEY.ALT_H,
31 + options = options,
32 + }
33 + map {
34 + description = 'Move line down',
35 + category = map.CATEGORY.EDITING,
36 + command = '<Plug>GoNSMDown',
37 + mode = map.MODE.NORMAL,
38 + keys = map.KEY.ALT_J,
39 + options = options,
40 + }
41 + map {
42 + description = 'Move line up',
43 + category = map.CATEGORY.EDITING,
44 + command = '<Plug>GoNSMUp',
45 + mode = map.MODE.NORMAL,
46 + keys = map.KEY.ALT_K,
47 + options = options,
48 + }
49 + map {
50 + description = 'Move character right',
51 + category = map.CATEGORY.EDITING,
52 + command = '<Plug>GoNSMRight',
53 + mode = map.MODE.NORMAL,
54 + keys = map.KEY.ALT_L,
55 + options = options,
56 + }
58 + -- VISUAL MOVE
59 + map {
60 + description = 'Move block left',
61 + category = map.CATEGORY.EDITING,
62 + command = '<Plug>GoVSMLeft',
63 + mode = map.MODE.VISUAL,
64 + keys = map.KEY.ALT_H,
65 + options = options,
66 + }
67 + map {
68 + description = 'Move block down',
69 + category = map.CATEGORY.EDITING,
70 + command = '<Plug>GoVSMDown',
71 + mode = map.MODE.VISUAL,
72 + keys = map.KEY.ALT_J,
73 + options = options,
74 + }
75 + map {
76 + description = 'Move block up',
77 + category = map.CATEGORY.EDITING,
78 + command = '<Plug>GoVSMUp',
79 + mode = map.MODE.VISUAL,
80 + keys = map.KEY.ALT_K,
81 + options = options,
82 + }
83 + map {
84 + description = 'Move block right',
85 + category = map.CATEGORY.EDITING,
86 + command = '<Plug>GoVSMRight',
87 + mode = map.MODE.VISUAL,
88 + keys = map.KEY.ALT_K,
89 + options = options,
90 + }
92 + -- NORMAL DUPLICATE
93 + map {
94 + description = 'Duplicate character left',
95 + category = map.CATEGORY.EDITING,
96 + command = '<Plug>GoNSDLeft',
97 + mode = map.MODE.NORMAL,
98 + keys = map.KEY.ALT_SHIFT_H,
99 + options = options,
101 + map {
102 + description = 'Duplicate line down',
103 + category = map.CATEGORY.EDITING,
104 + command = '<Plug>GoNSDDown',
105 + mode = map.MODE.NORMAL,
106 + keys = map.KEY.ALT_SHIFT_J,
107 + options = options,
109 + map {
110 + description = 'Duplicate line up',
111 + category = map.CATEGORY.EDITING,
112 + command = '<Plug>GoNSDUp',
113 + mode = map.MODE.NORMAL,
114 + keys = map.KEY.ALT_SHIFT_K,
115 + options = options,
117 + map {
118 + description = 'Duplicate character right',
119 + category = map.CATEGORY.EDITING,
120 + command = '<Plug>GoNSDRight',
121 + mode = map.MODE.NORMAL,
122 + keys = map.KEY.ALT_SHIFT_L,
123 + options = options,
126 + -- VISUAL DUPLICATE
127 + map {
128 + description = 'Duplicate block left',
129 + category = map.CATEGORY.EDITING,
130 + command = '<Plug>GoVSDLeft',
131 + mode = map.MODE.VISUAL,
132 + keys = map.KEY.ALT_SHIFT_H,
133 + options = options,
135 + map {
136 + description = 'Duplicate block down',
137 + category = map.CATEGORY.EDITING,
138 + command = '<Plug>GoVSDDown',
139 + mode = map.MODE.VISUAL,
140 + keys = map.KEY.ALT_SHIFT_J,
141 + options = options,
143 + map {
144 + description = 'Duplicate block up',
145 + category = map.CATEGORY.EDITING,
146 + command = '<Plug>GoVSDUp',
147 + mode = map.MODE.VISUAL,
148 + keys = map.KEY.ALT_SHIFT_K,
149 + options = options,
151 + map {
152 + description = 'Duplicate block right',
153 + category = map.CATEGORY.EDITING,
154 + command = '<Plug>GoVSDRight',
155 + mode = map.MODE.VISUAL,
156 + keys = map.KEY.ALT_SHIFT_L,
157 + options = options,

neovim/lua/bugabinga/options/init.lua

Modified
17 17 -- Disable some in built plugins completely
18 18 local disabled_built_ins = {
19 - 'netrw',
20 - 'netrwPlugin',
21 - 'netrwSettings',
22 - 'netrwFileHandlers',
23 - 'gzip',
24 - 'zip',
25 - 'zipPlugin',
26 - 'tar',
27 - 'tarPlugin',
28 - 'getscript',
29 - 'getscriptPlugin',
30 - 'vimball',
31 - 'vimballPlugin',
32 - '2html_plugin',
33 - 'logipat',
34 - 'rrhelper',
35 - 'spellfile_plugin',
36 - 'matchit',
37 - 'matchparen',
19 + 'netrw',
20 + 'netrwPlugin',
21 + 'netrwSettings',
22 + 'netrwFileHandlers',
23 + 'gzip',
24 + 'zip',
25 + 'zipPlugin',
26 + 'tar',
27 + 'tarPlugin',
28 + 'getscript',
29 + 'getscriptPlugin',
30 + 'vimball',
31 + 'vimballPlugin',
32 + '2html_plugin',
33 + 'logipat',
34 + 'rrhelper',
35 + 'spellfile_plugin',
36 + 'matchit',
37 + 'matchparen',
39 39 for _, plugin in pairs(disabled_built_ins) do
40 - vim.g['loaded_' .. plugin] = 1
40 + vim.g['loaded_' .. plugin] = 1

neovim/lua/bugabinga/options/keymaps.lua

Modified
1 1 local map = require 'bugabinga.std.keymap'
2 2 -- set <SPACE> as leader key
3 3 map {
4 - mode = map.MODE.ALL,
5 - keys = map.KEY.SPACE,
6 - command = map.COMMAND.NOP,
7 - visible = false,
4 + mode = map.MODE.ALL,
5 + keys = map.KEY.SPACE,
6 + command = map.COMMAND.NOP,
7 + visible = false,
9 9 vim.g.mapleader = ' '
10 10 vim.g.maplocalleader = ' '
12 12 -- disable default ENTER binding
13 13 map {
14 - mode = map.MODE.ALL,
15 - keys = map.KEY.ENTER,
16 - command = map.COMMAND.NOP,
17 - visible = false,
14 + mode = map.MODE.ALL,
15 + keys = map.KEY.ENTER,
16 + command = map.COMMAND.NOP,
17 + visible = false,
20 20 -- disable command history keymap, because i fatfinger it too often
23 23 -- when pausing between q and :, the binding still opens command history.
24 24 -- this may be related to the timeoutlen setting?
25 25 map {
26 - mode = map.MODE.ALL,
27 - keys = 'q:',
28 - command = map.COMMAND.NOP,
29 - visible = false,
26 + mode = map.MODE.ALL,
27 + keys = 'q:',
28 + command = map.COMMAND.NOP,
29 + visible = false,
31 31 map {
32 - mode = map.MODE.ALL,
33 - keys = 'q/',
34 - command = map.COMMAND.NOP,
35 - visible = false,
32 + mode = map.MODE.ALL,
33 + keys = 'q/',
34 + command = map.COMMAND.NOP,
35 + visible = false,
37 37 map {
38 - mode = map.MODE.ALL,
39 - keys = 'Q',
40 - command = map.COMMAND.NOP,
41 - visible = false,
38 + mode = map.MODE.ALL,
39 + keys = 'Q',
40 + command = map.COMMAND.NOP,
41 + visible = false,
43 43 -- disable them evil arrows
44 44 map {
45 - mode = map.MODE.ALL,
46 - keys = map.KEY.UP,
47 - command = map.COMMAND.NOP,
48 - visible = false,
45 + mode = map.MODE.ALL,
46 + keys = map.KEY.UP,
47 + command = map.COMMAND.NOP,
48 + visible = false,
50 50 map {
51 - mode = map.MODE.ALL,
52 - keys = map.KEY.DOWN,
53 - command = map.COMMAND.NOP,
54 - visible = false,
51 + mode = map.MODE.ALL,
52 + keys = map.KEY.DOWN,
53 + command = map.COMMAND.NOP,
54 + visible = false,
56 56 map {
57 - mode = map.MODE.ALL,
58 - keys = map.KEY.LEFT,
59 - command = map.COMMAND.NOP,
60 - visible = false,
57 + mode = map.MODE.ALL,
58 + keys = map.KEY.LEFT,
59 + command = map.COMMAND.NOP,
60 + visible = false,
62 62 map {
63 - mode = map.MODE.ALL,
64 - keys = map.KEY.RIGHT,
65 - command = map.COMMAND.NOP,
66 - visible = false,
63 + mode = map.MODE.ALL,
64 + keys = map.KEY.RIGHT,
65 + command = map.COMMAND.NOP,
66 + visible = false,
69 69 local function open_link_under_cursor()
70 - local file_under_cursor = vim.fn.expand '<cfile>'
71 - --check that it vaguely resembles an URI
72 - if file_under_cursor and file_under_cursor:match '%a+://.+' then
73 - local Job = require 'plenary.job'
74 - Job
75 - :new({
76 - --FIXME: a x-platform command is needed here
77 - command = 'firefox',
78 - args = { file_under_cursor },
79 - on_exit = function(status, code)
80 - print(status:result(), code)
81 - vim.notify('Openend ' .. file_under_cursor)
82 - end,
83 - })
84 - :start()
85 - end
70 + local file_under_cursor = vim.fn.expand '<cfile>'
71 + --check that it vaguely resembles an URI
72 + if file_under_cursor and file_under_cursor:match '%a+://.+' then
73 + local Job = require 'plenary.job'
74 + Job:new({
75 + --FIXME: a x-platform command is needed here
76 + command = 'firefox',
77 + args = { file_under_cursor },
78 + on_exit = function(status, code)
79 + print(status:result(), code)
80 + vim.notify('Openend ' .. file_under_cursor)
81 + end,
82 + }):start()
83 + end
88 86 map {
89 - description = 'Open web link under cursor in browser',
90 - category = map.CATEGORY.NAVIGATION,
91 - mode = map.MODE.NORMAL,
92 - keys = 'gx',
93 - command = open_link_under_cursor,
87 + description = 'Open web link under cursor in browser',
88 + category = map.CATEGORY.NAVIGATION,
89 + mode = map.MODE.NORMAL,
90 + keys = 'gx',
91 + command = open_link_under_cursor,
96 94 map {
97 - description = 'Dismiss current notifications',
98 - category = map.CATEGORY.NOTIFY,
99 - mode = map.MODE.NORMAL,
100 - keys = map.KEY.ESCAPE,
101 - command = function()pcall(vim.notify.dismiss)end,
95 + description = 'Dismiss current notifications',
96 + category = map.CATEGORY.NOTIFY,
97 + mode = map.MODE.NORMAL,
98 + keys = map.KEY.ESCAPE,
99 + command = function()
100 + pcall(vim.notify.dismiss)
101 + end,

neovim/lua/bugabinga/options/ui.lua

Modified
1 1 -- show trailing whitespace
2 2 vim.opt.list = true
3 3 vim.opt.listchars = {
4 - space = '⋅',
5 - eol = '↴',
6 - tab = '__',
7 - trail = '•',
8 - extends = '❯',
9 - precedes = '❮',
10 - nbsp = '_',
4 + space = '⋅',
5 + eol = '↴',
6 + tab = '__',
7 + trail = '•',
8 + extends = '❯',
9 + precedes = '❮',
10 + nbsp = '_',
13 13 -- do not spam the cmdline with every little input
29 29 -- hide weird symbol at end of buffer
30 30 vim.opt.fillchars = {
31 - eob = ' ',
32 - fold = ' ',
33 - diff = '╱',
31 + eob = ' ',
32 + fold = ' ',
33 + diff = '╱',
36 36 -- hide output of insert completion popup in status

neovim/lua/bugabinga/plugins/init.lua

Modified
1 1 local paq = require 'bugabinga.plugins.install'
2 2 paq {
3 - -- allow paq to manage itself
4 - 'savq/paq-nvim',
5 - -- caches other plugins for faster startup
6 - 'lewis6991/impatient.nvim',
7 - -- Utilities used by some plugins, e.g. telescope
8 - 'nvim-lua/plenary.nvim',
9 - -- collection of icons used by other plugins. needs a nerd font
10 - 'kyazdani42/nvim-web-devicons',
11 - -- fuzzy search ui over many parts of neovim and other plugins
12 - 'nvim-telescope/telescope.nvim',
13 - -- use telescope as `vim.ui.select`
14 - 'nvim-telescope/telescope-ui-select.nvim',
15 - -- use telescope as `vim.ui.input`
16 - 'stevearc/dressing.nvim',
17 - -- use frecency algorithm when sorting files. Needs sqlite3 installed
18 - 'nvim-telescope/telescope-frecency.nvim',
19 - -- display cheat sheet with telesope
20 - 'nvim-telescope/telescope-cheat.nvim',
21 - -- keep project specific histories in telescope
22 - 'nvim-telescope/telescope-smart-history.nvim',
23 - -- show file browser in telescope
24 - 'nvim-telescope/telescope-file-browser.nvim',
25 - -- manage projects via telescope
26 - 'nvim-telescope/telescope-project.nvim',
27 - -- pick a symbol (emoji, icon, kaomoji,...) via telescope
28 - 'nvim-telescope/telescope-symbols.nvim',
29 - -- sqplite lua bindings some plugins use
30 - 'tami5/sqlite.lua',
31 - -- status and tablines
32 - 'beauwilliams/statusline.lua',
33 - -- visual indicator if code actions are available
34 - 'kosayoda/nvim-lightbulb',
35 - -- some bug fix for LSP
36 - 'antoinemadec/FixCursorHold.nvim',
37 - -- allows statusbar plugins to query LSP
38 - 'nvim-lua/lsp-status.nvim',
39 - -- keybindings api that integrates into telescope to make keymaps searchable
40 - 'gfeiyou/command-center.nvim',
41 - -- search and replace
42 - 'nvim-pack/nvim-spectre',
43 - -- automatically manage window sizes based on focus
44 - 'beauwilliams/focus.nvim',
45 - -- avoid jitter in buffers when windows change
46 - 'luukvbaal/stabilize.nvim',
47 - -- keybindings that require a persistent chain
48 - 'anuvyklack/hydra.nvim',
49 - -- extends hydra with pink heads
50 - 'anuvyklack/keymap-layer.nvim',
51 - -- configure some editor settings according to editorconfig file, if present
52 - 'gpanders/editorconfig.nvim',
53 - -- highlight words under cursor
54 - -- "RRethy/vim-illuminate",
55 - -- highlight matched wors more clearly
56 - 'kevinhwang91/nvim-hlslens',
57 - -- draw lines to indicate indentation levels
58 - 'lukas-reineke/indent-blankline.nvim',
59 - -- move blocks of code around
60 - 'booperlv/nvim-gomove',
61 - -- toolkit for creating themes
62 - 'rktjmp/lush.nvim',
63 - -- theme with colors i like
64 - 'rockerBOO/boo-colorscheme-nvim',
65 - -- display the colorcolumn as a virtual character
66 - 'lukas-reineke/virt-column.nvim',
67 - -- jump cursor to last known position on neovim start
68 - 'ethanholz/nvim-lastplace',
69 - -- smooth scrolling for movement
70 - 'declancm/cinnamon.nvim',
71 - -- fast navigation in buffer via shortcut labels
72 - 'ggandor/leap.nvim',
73 - -- breadcrumbs in window bar
74 - 'SmiteshP/nvim-navic',
75 - -- show color values inline
76 - -- this plugins seems a little unmaintained right now.
77 - -- using some forks for now
78 - --'norcalli/nvim-colorizer.lua',
79 - --'NvChad/nvim-colorizer.lua',
80 - 'lasse16/nvim-colorizer.lua',
81 - -- intelligent commenting
82 - 'numToStr/Comment.nvim',
83 - -- show git status in ui
84 - 'lewis6991/gitsigns.nvim',
85 - -- sexy start page
86 - 'goolord/alpha-nvim',
87 - -- extend vim.notify with fancy ui
88 - 'rcarriga/nvim-notify',
89 - -- show registers ui
90 - 'tversteeg/registers.nvim',
91 - -- markdown editor
92 - -- 'jakewvincent/mkdnflow.nvim',
93 - -- highlight TODOs and collect them
94 - 'folke/todo-comments.nvim',
95 - -- centralized view for code issues
96 - 'folke/trouble.nvim',
97 - -- faster access to terminal
98 - 'akinsho/toggleterm.nvim',
99 - -- File Browser
100 - {
101 - 'nvim-neo-tree/neo-tree.nvim',
102 - branch = 'v2.x',
103 - },
104 - -- ui elements for other plugins
105 - 'MunifTanjim/nui.nvim',
106 - -- window picker component for other plugins
107 - {
108 - 's1n7ax/nvim-window-picker',
109 - branch = 'v1.3',
110 - },
111 - -- clipboard/yank history
112 - 'AckslD/nvim-neoclip.lua',
113 - -- the treesitter parser is not compatible with current nushell for now
114 - -- {
115 - -- 'LhKipp/nvim-nu',
116 - -- run = function() require'nvim-treesitter.install'.ensure_installed('nu') end,
117 - -- },
118 - -- smart parser for syntax
119 - {
120 - 'nvim-treesitter/nvim-treesitter',
121 - run = function()
122 - require('nvim-treesitter.install').update()
123 - end,
124 - },
125 - -- extend treesittier with light refactorings
126 - 'nvim-treesitter/nvim-treesitter-refactor',
127 - -- add movement around structural syntax elements
128 - 'nvim-treesitter/nvim-treesitter-textobjects',
129 - -- expand selection based on structure
130 - 'RRethy/nvim-treesitter-textsubjects',
131 - -- highlight function arguments
132 - 'm-demare/hlargs.nvim',
133 - -- inspect treesitter queries and get helpful functions
134 - 'nvim-treesitter/playground',
135 - -- set commentstring when in polyglot files
136 - 'JoosepAlviste/nvim-ts-context-commentstring',
137 - -- generate doc comment boilerplate
138 - 'danymat/neogen',
139 - -- automatically change corresponding tag, when editing markup (xml/html)
140 - 'windwp/nvim-ts-autotag',
141 - -- autoclose pairs on enter and completion
142 - 'windwp/nvim-autopairs',
143 - -- glue, that binds all the neovim lsp crap
144 - 'VonHeikemen/lsp-zero.nvim',
145 - -- LSP Support
146 - 'neovim/nvim-lspconfig',
147 - 'williamboman/nvim-lsp-installer',
148 - 'simrat39/symbols-outline.nvim',
149 - -- Autocompletion
150 - 'hrsh7th/nvim-cmp',
151 - 'hrsh7th/cmp-buffer',
152 - 'hrsh7th/cmp-path',
153 - 'hrsh7th/cmp-nvim-lsp-document-symbol',
154 - 'saadparwaiz1/cmp_luasnip',
155 - 'hrsh7th/cmp-nvim-lsp',
156 - 'hrsh7th/cmp-nvim-lua',
157 - -- Snippets
158 - 'L3MON4D3/LuaSnip',
159 - 'rafamadriz/friendly-snippets',
160 - -- rust development
161 - 'simrat39/rust-tools.nvim',
162 - -- java development
163 - 'mfussenegger/nvim-jdtls',
164 - -- lua neovim config development
165 - 'folke/lua-dev.nvim',
166 - -- fake lsp to pipe in non-lsp tools, like formatters, into lsp api
167 - 'jose-elias-alvarez/null-ls.nvim',
168 - -- Special Java LSP integration sauce
169 - 'mfussenegger/nvim-jdtls',
170 - -- debug adapter protocol
171 - 'mfussenegger/nvim-dap',
172 - -- repls in neovim
173 - 'hkupty/iron.nvim',
174 - -- color picker
175 - 'ziontee113/color-picker.nvim',
176 - -- motions around object
177 - 'kylechui/nvim-surround',
3 + -- allow paq to manage itself
4 + 'savq/paq-nvim',
5 + -- caches other plugins for faster startup
6 + 'lewis6991/impatient.nvim',
7 + -- Utilities used by some plugins, e.g. telescope
8 + 'nvim-lua/plenary.nvim',
9 + -- collection of icons used by other plugins. needs a nerd font
10 + 'kyazdani42/nvim-web-devicons',
11 + -- fuzzy search ui over many parts of neovim and other plugins
12 + 'nvim-telescope/telescope.nvim',
13 + -- use telescope as `vim.ui.select`
14 + 'nvim-telescope/telescope-ui-select.nvim',
15 + -- use telescope as `vim.ui.input`
16 + 'stevearc/dressing.nvim',
17 + -- use frecency algorithm when sorting files. Needs sqlite3 installed
18 + 'nvim-telescope/telescope-frecency.nvim',
19 + -- display cheat sheet with telesope
20 + 'nvim-telescope/telescope-cheat.nvim',
21 + -- keep project specific histories in telescope
22 + 'nvim-telescope/telescope-smart-history.nvim',
23 + -- show file browser in telescope
24 + 'nvim-telescope/telescope-file-browser.nvim',
25 + -- manage projects via telescope
26 + 'nvim-telescope/telescope-project.nvim',
27 + -- pick a symbol (emoji, icon, kaomoji,...) via telescope
28 + 'nvim-telescope/telescope-symbols.nvim',
29 + -- sqplite lua bindings some plugins use
30 + 'tami5/sqlite.lua',
31 + -- status and tablines
32 + 'beauwilliams/statusline.lua',
33 + -- visual indicator if code actions are available
34 + 'kosayoda/nvim-lightbulb',
35 + -- some bug fix for LSP
36 + 'antoinemadec/FixCursorHold.nvim',
37 + -- allows statusbar plugins to query LSP
38 + 'nvim-lua/lsp-status.nvim',
39 + -- keybindings api that integrates into telescope to make keymaps searchable
40 + 'gfeiyou/command-center.nvim',
41 + -- search and replace
42 + 'nvim-pack/nvim-spectre',
43 + -- automatically manage window sizes based on focus
44 + 'beauwilliams/focus.nvim',
45 + -- avoid jitter in buffers when windows change
46 + 'luukvbaal/stabilize.nvim',
47 + -- keybindings that require a persistent chain
48 + 'anuvyklack/hydra.nvim',
49 + -- extends hydra with pink heads
50 + 'anuvyklack/keymap-layer.nvim',
51 + -- configure some editor settings according to editorconfig file, if present
52 + 'gpanders/editorconfig.nvim',
53 + -- highlight words under cursor
54 + -- "RRethy/vim-illuminate",
55 + -- highlight matched wors more clearly
56 + 'kevinhwang91/nvim-hlslens',
57 + -- draw lines to indicate indentation levels
58 + 'lukas-reineke/indent-blankline.nvim',
59 + -- move blocks of code around
60 + 'booperlv/nvim-gomove',
61 + -- toolkit for creating themes
62 + 'rktjmp/lush.nvim',
63 + -- theme with colors i like
64 + 'rockerBOO/boo-colorscheme-nvim',
65 + -- display the colorcolumn as a virtual character
66 + 'lukas-reineke/virt-column.nvim',
67 + -- jump cursor to last known position on neovim start
68 + 'ethanholz/nvim-lastplace',
69 + -- smooth scrolling for movement
70 + 'declancm/cinnamon.nvim',
71 + -- fast navigation in buffer via shortcut labels
72 + 'ggandor/leap.nvim',
73 + -- breadcrumbs in window bar
74 + 'SmiteshP/nvim-navic',
75 + -- show color values inline
76 + -- this plugins seems a little unmaintained right now.
77 + -- using some forks for now
78 + --'norcalli/nvim-colorizer.lua',
79 + --'NvChad/nvim-colorizer.lua',
80 + 'lasse16/nvim-colorizer.lua',
81 + -- intelligent commenting
82 + 'numToStr/Comment.nvim',
83 + -- show git status in ui
84 + 'lewis6991/gitsigns.nvim',
85 + -- sexy start page
86 + 'goolord/alpha-nvim',
87 + -- extend vim.notify with fancy ui
88 + 'rcarriga/nvim-notify',
89 + -- show registers ui
90 + 'tversteeg/registers.nvim',
91 + -- markdown editor
92 + -- 'jakewvincent/mkdnflow.nvim',
93 + -- highlight TODOs and collect them
94 + 'folke/todo-comments.nvim',
95 + -- centralized view for code issues
96 + 'folke/trouble.nvim',
97 + -- faster access to terminal
98 + 'akinsho/toggleterm.nvim',
99 + -- File Browser
101 + 'nvim-neo-tree/neo-tree.nvim',
102 + branch = 'v2.x',
103 + },
104 + -- ui elements for other plugins
105 + 'MunifTanjim/nui.nvim',
106 + -- window picker component for other plugins
108 + 's1n7ax/nvim-window-picker',
109 + branch = 'v1.3',
110 + },
111 + -- clipboard/yank history
112 + 'AckslD/nvim-neoclip.lua',
113 + -- the treesitter parser is not compatible with current nushell for now
114 + -- {
115 + -- 'LhKipp/nvim-nu',
116 + -- run = function() require'nvim-treesitter.install'.ensure_installed('nu') end,
117 + -- },
118 + -- smart parser for syntax
120 + 'nvim-treesitter/nvim-treesitter',
121 + run = function()
122 + require('nvim-treesitter.install').update()
123 + end,
124 + },
125 + -- extend treesittier with light refactorings
126 + 'nvim-treesitter/nvim-treesitter-refactor',
127 + -- add movement around structural syntax elements
128 + 'nvim-treesitter/nvim-treesitter-textobjects',
129 + -- expand selection based on structure
130 + 'RRethy/nvim-treesitter-textsubjects',
131 + -- highlight function arguments
132 + 'm-demare/hlargs.nvim',
133 + -- inspect treesitter queries and get helpful functions
134 + 'nvim-treesitter/playground',
135 + -- set commentstring when in polyglot files
136 + 'JoosepAlviste/nvim-ts-context-commentstring',
137 + -- generate doc comment boilerplate
138 + 'danymat/neogen',
139 + -- automatically change corresponding tag, when editing markup (xml/html)
140 + 'windwp/nvim-ts-autotag',
141 + -- autoclose pairs on enter and completion
142 + 'windwp/nvim-autopairs',
143 + -- glue, that binds all the neovim lsp crap
144 + 'VonHeikemen/lsp-zero.nvim',
145 + -- LSP Support
146 + 'neovim/nvim-lspconfig',
147 + 'williamboman/nvim-lsp-installer',
148 + 'simrat39/symbols-outline.nvim',
149 + -- Autocompletion
150 + 'hrsh7th/nvim-cmp',
151 + 'hrsh7th/cmp-buffer',
152 + 'hrsh7th/cmp-path',
153 + 'hrsh7th/cmp-nvim-lsp-document-symbol',
154 + 'saadparwaiz1/cmp_luasnip',
155 + 'hrsh7th/cmp-nvim-lsp',
156 + 'hrsh7th/cmp-nvim-lua',
157 + -- Snippets
158 + 'L3MON4D3/LuaSnip',
159 + 'rafamadriz/friendly-snippets',
160 + -- rust development
161 + 'simrat39/rust-tools.nvim',
162 + -- java development
163 + 'mfussenegger/nvim-jdtls',
164 + -- lua neovim config development
165 + 'folke/lua-dev.nvim',
166 + -- fake lsp to pipe in non-lsp tools, like formatters, into lsp api
167 + 'jose-elias-alvarez/null-ls.nvim',
168 + -- Special Java LSP integration sauce
169 + 'mfussenegger/nvim-jdtls',
170 + -- debug adapter protocol
171 + 'mfussenegger/nvim-dap',
172 + -- repls in neovim
173 + 'hkupty/iron.nvim',
174 + -- color picker
175 + 'ziontee113/color-picker.nvim',
176 + -- motions around object
177 + 'kylechui/nvim-surround',
179 179 -- local plugins. they may override plugins from above
180 180 vim.opt.runtimepath:append '~/Workspace/lsp-zero.nvim'

neovim/lua/bugabinga/std/keymap.lua

Modified
1 1 local want = require 'bugabinga.std.want'
2 -local bind = want { 'command_center' } (function(command_center)
3 - return function(map)
4 - map.visible = map.visible == nil or map.visible
5 - map.options = map.options or {}
6 - local options = vim.tbl_extend('keep', map.options, { silent = true })
7 - if map.visible then
8 - command_center.add({
9 - {
10 - description = map.description,
11 - category = map.category,
12 - cmd = map.command,
13 - keybindings = { map.mode, map.keys, options },
14 - },
15 - }, command_center.mode.ADD_ONLY)
16 - end
17 - -- use neovim api to add keybind instead of command_center, because it has
18 - -- nicer defaults.
19 - vim.keymap.set(map.mode, map.keys, map.command, options)
20 - end
2 +local bind = want { 'command_center' }(function(command_center)
3 + return function(map)
4 + map.visible = map.visible == nil or map.visible
5 + map.options = map.options or {}
6 + local options = vim.tbl_extend('keep', map.options, {
7 + silent = true,
8 + desc = map.description,
9 + })
10 + if map.visible then
11 + local keybindings = {}
12 + if type(map.mode) == 'table' then
13 + for _, mode in ipairs(map.mode) do
14 + table.insert(keybindings, { mode, map.keys })
15 + end
16 + else
17 + keybindings = { map.mode, map.keys }
18 + end
19 + command_center.add({
20 + {
21 + description = map.description,
22 + category = map.category,
23 + cmd = map.command,
24 + keybindings = keybindings,
25 + },
26 + }, command_center.mode.ADD_ONLY)
27 + end
28 + -- use neovim api to add keybind instead of command_center, because it has
29 + -- nicer defaults.
30 + vim.keymap.set(map.mode, map.keys, map.command, options)
31 + end
21 32 end)
23 34 return setmetatable({
24 - MODE = {
25 - NORMAL = 'n',
26 - ALL = '',
27 - },
28 - KEY = {
29 - SPACE = '<SPACE>',
30 - ENTER = '<CR>',
31 - ESCAPE = '<ESC>',
32 - UP = '<Up>',
33 - DOWN = '<Down>',
34 - LEFT = '<Left>',
35 - RIGHT = '<Right>',
36 - },
37 - COMMAND = {
38 - NOP = function() end,
39 - },
40 - CATEGORY = {
41 - NAVIGATION = 'navigation',
42 - NOTIFY = 'notify',
43 - },
35 + MODE = {
36 + NORMAL = 'n',
37 + VISUAL = 'x',
38 + ALL = '',
39 + },
40 + KEY = {
41 + SPACE = '<SPACE>',
42 + ENTER = '<CR>',
43 + ESCAPE = '<ESC>',
44 + UP = '<Up>',
45 + DOWN = '<Down>',
46 + LEFT = '<Left>',
47 + RIGHT = '<Right>',
48 + ALT_H = '<A-h>',
49 + ALT_J = '<A-j>',
50 + ALT_K = '<A-k>',
51 + ALT_L = '<A-l>',
52 + ALT_SHIFT_H = '<A-H>',
53 + ALT_SHIFT_J = '<A-J>',
54 + ALT_SHIFT_K = '<A-K>',
55 + ALT_SHIFT_L = '<A-L>',
56 + },
57 + COMMAND = {
58 + NOP = function() end,
59 + },
60 + CATEGORY = {
61 + NAVIGATION = 'navigation',
62 + EDITING = 'editing',
63 + NOTIFY = 'notify',
64 + },
44 65 }, {
45 - __call = function(_, ...)
46 - return bind(...)
47 - end,
66 + __call = function(_, ...)
67 + return bind(...)
68 + end,

neovim/lua/bugabinga/std/project.lua

Modified
27 27 ---@param root string The last directory on the path to root, when to stop searching. Usually '/' or '~'.
28 28 ---@return string? #A directory, that contains the `markers` and lies on the path from `directory` to `root`.
29 29 local function determine_root(directory, markers, root)
30 - local dirname = function(path)
31 - return vim.fn.fnamemodify(path, ':h')
32 - end
33 - local exists = function(path)
34 - return vim.loop.fs_stat(path)
35 - end
36 - local directory_scores = {}
37 - local current_distance_to_buffer = 0
38 - --traverse the path to root and check every directory on the way for files
39 - --that are named like the given markers. if markers exist, add those to the
40 - --score of the directory. scores of all directories with markers will be
41 - --processes later.
42 - --the root itself never gets checked for markers!
43 - -- stop if we reached the user defined root instead of the file system root
44 - while directory ~= root do
45 - local score = {
46 - path = directory,
47 - marker_count = 0,
48 - distance_to_buffer_file = current_distance_to_buffer,
49 - markers = {},
50 - }
30 + local dirname = function(path)
31 + return vim.fn.fnamemodify(path, ':h')
32 + end
33 + local exists = function(path)
34 + return vim.loop.fs_stat(path)
35 + end
36 + local directory_scores = {}
37 + local current_distance_to_buffer = 0
38 + --traverse the path to root and check every directory on the way for files
39 + --that are named like the given markers. if markers exist, add those to the
40 + --score of the directory. scores of all directories with markers will be
41 + --processes later.
42 + --the root itself never gets checked for markers!
43 + -- stop if we reached the user defined root instead of the file system root
44 + while directory ~= root do
45 + local score = {
46 + path = directory,
47 + marker_count = 0,
48 + distance_to_buffer_file = current_distance_to_buffer,
49 + markers = {},
50 + }
52 - for _, marker in ipairs(markers) do
53 - local marker_path = directory .. '/' .. marker.name
54 - if exists(marker_path) then
55 - score.marker_count = score.marker_count + marker.weight
56 - table.insert(score.markers, marker_path)
57 - end
58 - end
52 + for _, marker in ipairs(markers) do
53 + local marker_path = directory .. '/' .. marker.name
54 + if exists(marker_path) then
55 + score.marker_count = score.marker_count + marker.weight
56 + table.insert(score.markers, marker_path)
57 + end
58 + end
60 - if score.marker_count > 0 then
61 - table.insert(directory_scores, score)
62 - end
60 + if score.marker_count > 0 then
61 + table.insert(directory_scores, score)
62 + end
64 - directory = dirname(directory)
65 - current_distance_to_buffer = current_distance_to_buffer + 1
66 - end
64 + directory = dirname(directory)
65 + current_distance_to_buffer = current_distance_to_buffer + 1
66 + end
68 - local project_root = nil
69 - local max_likelyhood = 0
70 - -- the project root is most likely the directory with the highest marker count
71 - -- and distance to current buffer.
72 - -- because if there are markers further away from the buffer than other markers,
73 - -- then it is most likely a nested project structure (multi-module).
74 - -- in those cases we are looking for the root project folder, instead the nearest
75 - -- child project root folder.
76 - for _, score in ipairs(directory_scores) do
77 - local likelihood = score.marker_count + score.distance_to_buffer_file
78 - if likelihood > max_likelyhood then
79 - max_likelyhood = likelihood
80 - project_root = score.path
81 - end
82 - end
83 - return project_root
68 + local project_root = nil
69 + local max_likelyhood = 0
70 + -- the project root is most likely the directory with the highest marker count
71 + -- and distance to current buffer.
72 + -- because if there are markers further away from the buffer than other markers,
73 + -- then it is most likely a nested project structure (multi-module).
74 + -- in those cases we are looking for the root project folder, instead the nearest
75 + -- child project root folder.
76 + for _, score in ipairs(directory_scores) do
77 + local likelihood = score.marker_count + score.distance_to_buffer_file
78 + if likelihood > max_likelyhood then
79 + max_likelyhood = likelihood
80 + project_root = score.path
81 + end
82 + end
83 + return project_root
86 86 --- Determines the project root directory of the current buffer file. A "project" is not clearly defined for all programming languages, so this function uses a heuristic approach.
88 88 ---@param custom_root string Given a `custom_root` the path traversal can be aborted before the filesystem root is reached. A useful value might be `~` for example, if your source code is always in your home directory. the root directory itself does __not__ get searched for markers!
89 89 ---@return string project_root The project root of the current buffer, or `nil`, if none could be determined.
90 90 local function determine_project_root(custom_markers, custom_root)
91 - -- glob expands user defined root and checks, that it exists
92 - local root = vim.fn.glob(custom_root, false, false)
93 - if root == '' then
94 - vim.notify('the custom root ' .. custom_root .. ' does not exist!', error)
95 - return nil
96 - end
97 - -- define some language-independent markers
98 - local markers = {
99 - { name = '.git', weight = 1 },
100 - { name = '.gitignore', weight = 1 },
101 - { name = '.svn', weight = 1 },
102 - { name = 'justfile', weight = 1 },
103 - { name = 'Jenkinsfile', weight = 1 },
104 - { name = '.editorconfig', weight = 1 },
105 - { name = 'LICENSE', weight = 1 },
106 - { name = 'LICENSE.txt', weight = 1 },
107 - { name = 'COPYING', weight = 1 },
108 - { name = 'README', weight = 1 },
109 - { name = 'README.md', weight = 1 },
110 - }
111 - markers = vim.tbl_deep_extend('force', markers, custom_markers)
91 + -- glob expands user defined root and checks, that it exists
92 + local root = vim.fn.glob(custom_root, false, false)
93 + if root == '' then
94 + vim.notify('the custom root ' .. custom_root .. ' does not exist!', error)
95 + return nil
96 + end
97 + -- define some language-independent markers
98 + local markers = {
99 + { name = '.git', weight = 1 },
100 + { name = '.gitignore', weight = 1 },
101 + { name = '.svn', weight = 1 },
102 + { name = 'justfile', weight = 1 },
103 + { name = 'Jenkinsfile', weight = 1 },
104 + { name = '.editorconfig', weight = 1 },
105 + { name = 'LICENSE', weight = 1 },
106 + { name = 'LICENSE.txt', weight = 1 },
107 + { name = 'COPYING', weight = 1 },
108 + { name = 'README', weight = 1 },
109 + { name = 'README.md', weight = 1 },
111 + markers = vim.tbl_deep_extend('force', markers, custom_markers)
113 - local buffer_name = vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf())
114 - local directory_name = vim.fn.fnamemodify(buffer_name, ':p:h')
115 - return determine_root(directory_name, markers, root)
113 + local buffer_name = vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf())
114 + local directory_name = vim.fn.fnamemodify(buffer_name, ':p:h')
115 + return determine_root(directory_name, markers, root)
118 118 local java_markers = {
119 - { name = '.idea', weight = 2 },
120 - { name = '.classpath', weight = 2 },
121 - { name = '.settings', weight = 2 },
122 - { name = '.project', weight = 2 },
123 - { name = 'target', weight = 2 },
124 - { name = 'pom.xml', weight = 2 },
125 - { name = 'mvnw', weight = 3 },
126 - { name = '.mvn', weight = 3 },
127 - { name = 'mvnw.cmd', weight = 3 },
128 - { name = 'build.gradle', weight = 2 },
129 - { name = 'gradle.properties', weight = 3 },
130 - { name = 'settings.gradle', weight = 3 },
131 - { name = 'gradlew', weight = 3 },
132 - { name = 'gradlew.bat', weight = 3 },
119 + { name = '.idea', weight = 2 },
120 + { name = '.classpath', weight = 2 },
121 + { name = '.settings', weight = 2 },
122 + { name = '.project', weight = 2 },
123 + { name = 'target', weight = 2 },
124 + { name = 'pom.xml', weight = 2 },
125 + { name = 'mvnw', weight = 3 },
126 + { name = '.mvn', weight = 3 },
127 + { name = 'mvnw.cmd', weight = 3 },
128 + { name = 'build.gradle', weight = 2 },
129 + { name = 'gradle.properties', weight = 3 },
130 + { name = 'settings.gradle', weight = 3 },
131 + { name = 'gradlew', weight = 3 },
132 + { name = 'gradlew.bat', weight = 3 },
134 134 local function determine_java_project_root(user_root)
135 - return determine_project_root(java_markers, user_root)
135 + return determine_project_root(java_markers, user_root)
138 138 local function is_java_project_root(directory, user_root)
139 - -- avoid determine_project_root to __not__ check non-java markers
140 - return determine_root(directory, java_markers, user_root) ~= nil
139 + -- avoid determine_project_root to __not__ check non-java markers
140 + return determine_root(directory, java_markers, user_root) ~= nil
143 143 return {
144 - is_java_project_root = is_java_project_root,
145 - determine_root = determine_root,
146 - determine_project_root = determine_project_root,
147 - determine_java_project_root = determine_java_project_root,
144 + is_java_project_root = is_java_project_root,
145 + determine_root = determine_root,
146 + determine_project_root = determine_project_root,
147 + determine_java_project_root = determine_java_project_root,

neovim/lua/bugabinga/windows.lua

Modified
1 1 local want = require 'bugabinga.std.want'
2 2 want {
3 - 'focus',
4 - 'stabilize',
5 -} (function(focus, stabilize)
6 - local excluded_filetypes = { 'toggleterm', 'qf', 'help', 'Trouble', 'neo-tree' }
3 + 'focus',
4 + 'stabilize',
5 +}(function(focus, stabilize)
6 + local excluded_filetypes = { 'toggleterm', 'qf', 'help', 'Trouble', 'neo-tree' }
8 - focus.setup {
9 - excluded_filetypes = excluded_filetypes,
10 - excluded_buftypes = { 'nofile', 'prompt', 'popup', 'help', 'terminal' },
11 - compatible_filetrees = { 'neo-tree' },
12 - cursorline = false,
13 - signcolumn = false,
14 - }
8 + focus.setup {
9 + excluded_filetypes = excluded_filetypes,
10 + excluded_buftypes = { 'nofile', 'prompt', 'popup', 'help', 'terminal' },
11 + compatible_filetrees = { 'neo-tree' },
12 + cursorline = false,
13 + signcolumn = false,
14 + }
16 - stabilize.setup()
16 + stabilize.setup()
17 17 end)