repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim: more lsp clients

a08fbfa69f08e3b42ca24af517daeace0828d47e

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (29)

helix/languages.toml

Modified
1 -[[language]]
1 +[[languages]]
2 2 name = "nasm"
3 3 language-server = { command = "asm-lsp" }
5 -[[language]]
5 +[[languages]]
6 6 name = "xml"
7 7 auto-format = false
8 8 language-server = { command = "lemminx" }

neovim/init.lua

Modified
19 19 -- TODO:
20 20 -- [ ] use ltex-ls for markdown, code comments and commit messages
21 --- [ ] use nvimjdtls
22 21 -- [ ] DAP
23 --- [ ] nugu theme
24 22 -- [ ] add nu-check to nvim-lint
23 +-- [ ] Semantic Highlighting: https://gist.github.com/swarn/fb37d9eefe1bc616c2a7e476c0bc0316

neovim/lazy-lock.json

Modified
7 7 "flash.nvim": { "branch": "main", "commit": "e5a7bd96d0bb7e0806bfc18adea5ab148165bd62" },
8 8 "gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" },
9 9 "glow.nvim": { "branch": "main", "commit": "cf2177a514859fa3c55837b46de91d93b24cf488" },
10 - "heirline.nvim": { "branch": "master", "commit": "76136ccd93ed608e8109762f032cf1118981ebbd" },
10 + "heirline.nvim": { "branch": "master", "commit": "7f1e805dfc001d5dbb7d894105063f463f6c7dcc" },
11 11 "hlargs.nvim": { "branch": "main", "commit": "cfc9beab4e176a13311efe03e38e6b6fed5df4f6" },
12 + "hydra.nvim": { "branch": "master", "commit": "ceb1fb7e3b4916676674e8a4253deea5a19ab01f" },
12 13 "inc-rename.nvim": { "branch": "main", "commit": "ed0f6f2b917cac4eb3259f907da0a481b27a3b7e" },
13 14 "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" },
14 15 "lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" },
15 16 "lush.nvim": { "branch": "main", "commit": "a8f0f7b9f837887f13a61d67b40ae26188fe4d62" },
16 - "mason.nvim": { "branch": "main", "commit": "74eac861b013786bf231b204b4ba9a7d380f4bd9" },
17 + "mason.nvim": { "branch": "main", "commit": "d66c60e17dd6fd8165194b1d14d21f7eb2c1697a" },
18 + "multicursors.nvim": { "branch": "main", "commit": "65dd5e4eb007cf5796e663ecfa2a2a27cba9d1b7" },
17 19 "neodev.nvim": { "branch": "main", "commit": "da1562e1e3df0e994ddc52cb4ba22376a5d7f2fc" },
18 20 "neogen": { "branch": "main", "commit": "cb1f384df804c1bf729332c4f728253fe17962d4" },
19 - "noice.nvim": { "branch": "main", "commit": "894db25ec726d32047799d4d0a982b701bec453b" },
21 + "noice.nvim": { "branch": "main", "commit": "791c7adda821fd03529f995df2ee284ad591dabd" },
20 22 "nrpattern.nvim": { "branch": "master", "commit": "f862ce687761078ef3155688151c55f69d28453e" },
21 23 "nui.nvim": { "branch": "main", "commit": "9e3916e784660f55f47daa6f26053ad044db5d6a" },
22 - "nvim-autopairs": { "branch": "master", "commit": "ae5b41ce880a6d850055e262d6dfebd362bb276e" },
24 + "nvim-autopairs": { "branch": "master", "commit": "defad64afbf19381fe31488a7582bbac421d6e38" },
23 25 "nvim-cmp": { "branch": "main", "commit": "983453e32cb35533a119725883c04436d16c0120" },
24 26 "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" },
25 - "nvim-genghis": { "branch": "main", "commit": "13b773cb3935b25962b0e00ff0795cce6be2eb1e" },
27 + "nvim-genghis": { "branch": "main", "commit": "c3f043860f02370bfe9bba24f0c93658d01dd6ea" },
26 28 "nvim-gomove": { "branch": "main", "commit": "2b44ae7ac0804f4e3959228122f7c85bef1964e3" },
27 29 "nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" },
28 30 "nvim-neoclip.lua": { "branch": "main", "commit": "4e406ae0f759262518731538f2585abb9d269bac" },
29 31 "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" },
30 32 "nvim-surround": { "branch": "main", "commit": "0d6882635817a2677749a330127d12ac30a4f3c8" },
31 - "nvim-treesitter": { "branch": "master", "commit": "4d41d9bfb09dd0836ce6910404e3cd570500c9ca" },
33 + "nvim-treesitter": { "branch": "master", "commit": "48b237fd3f482aef2f5896b8b7a6ece71c19ad99" },
32 34 "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },
33 - "nvim-ts-context-commentstring": { "branch": "main", "commit": "9bff161dfece6ecf3459e6e46ca42e49f9ed939f" },
34 - "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" },
35 - "oil.nvim": { "branch": "master", "commit": "2fde9d84fcead6c61a59388fe29bd3135c39fa94" },
35 + "nvim-ts-context-commentstring": { "branch": "main", "commit": "95e9ba9de4289d221666b66fd930d157c7ca08c6" },
36 + "nvim-web-devicons": { "branch": "master", "commit": "973ab742f143a796a779af4d786ec409116a0d87" },
37 + "oil.nvim": { "branch": "master", "commit": "fdb50dc5c57524c4b0b05b593abff4d4f7a099f6" },
36 38 "persistence.nvim": { "branch": "main", "commit": "adcf6913693a0434665d162ee45a186230496f8a" },
37 - "playground": { "branch": "master", "commit": "2b81a018a49f8e476341dfcb228b7b808baba68b" },
39 + "playground": { "branch": "master", "commit": "429f3e76cbb1c59fe000b690f7a5bea617b890c0" },
38 40 "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" },
39 - "refactoring.nvim": { "branch": "master", "commit": "2cfd6ddb0acece95d9658560ae9740b98ef70dbb" },
41 + "refactoring.nvim": { "branch": "master", "commit": "2ec9bc0fb5f3c8c6a0f776f0159dd2a3b1663554" },
40 42 "schemastore.nvim": { "branch": "main", "commit": "ce624332e6ba5a9a0c8f311a114ac179c5e72f62" },
41 43 "specs.nvim": { "branch": "main", "commit": "2743e412bbe21c9d73954c403d01e8de7377890d" },
42 44 "substitute.nvim": { "branch": "main", "commit": "42d09f1e6324d98aa2e5b765b64528e0aefe72b0" },
43 45 "telescope-symbols.nvim": { "branch": "master", "commit": "f2060117d965df4a626f068a4ebbd8ee051aa076" },
44 - "telescope.nvim": { "branch": "0.1.x", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" },
46 + "telescope-ui-select.nvim": { "branch": "master", "commit": "62ea5e58c7bbe191297b983a9e7e89420f581369" },
47 + "telescope-zoxide": { "branch": "main", "commit": "68966349aa1b8e9ade403e18479ecf79447389a7" },
48 + "telescope.nvim": { "branch": "0.1.x", "commit": "54930e1abfc94409e1bb9266e752ef8379008592" },
45 49 "todo-comments.nvim": { "branch": "main", "commit": "8febc60a76feefd8203077ef78b6a262ea1a41f9" },
46 50 "toggleterm.nvim": { "branch": "main", "commit": "b90a1381e9b5b8596f49070ee86c71db267ac868" },
47 51 "treesj": { "branch": "main", "commit": "bff8c32b826e188fa558e94c7c93ac17a8ef0365" },

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

Added
new file mode 100644
1 +local project = require'std.project'
3 +return {
4 + name = 'pkgbuild-language-server',
5 + command = 'pkgbuild-language-server',
6 + filetypes = { 'PKGBUILD' },
7 + root_dir = project.find_vcs_project_root,
8 + single_file_support = true,
9 + workspaces = false,

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

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

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

Added
new file mode 100644
1 +local project = require'std.project'
3 +return {
4 + name = 'bash-lsp',
5 + command = { 'bash-language-server', 'start' } ,
6 + filetypes = { 'sh' },
7 + root_dir = project.find_vcs_project_root,
8 + single_file_support = true,
9 + workspaces = false,
10 + settings = {
11 + bashIde = {
12 + -- Glob pattern for finding and parsing shell script files in the workspace.
13 + -- Used by the background analysis features across files.
15 + -- Prevent recursive scanning which will cause issues when opening a file
16 + -- directly in the home directory (e.g. ~/foo.sh).
17 + --
18 + -- Default upstream pattern is "**/*@(.sh|.inc|.bash|.command)".
19 + globPattern = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command)',
20 + },
21 + },

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

Added
new file mode 100644
1 +local project = require'std.project'
3 +return {
4 + name = 'clangd',
5 + command = 'clangd',
6 + filetypes = 'c',
7 + root_dir = project.find_vcs_project_root,
8 + single_file_support = true,
9 + workspaces = true,
10 + capabilities = {
11 + textDocument = {
12 + completion = {
13 + editsNearCursor = true,
14 + },
15 + },
16 + offsetEncoding = { 'utf-8', 'utf-16' },
17 + },

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

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

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

Modified
1 1 local lua = require'bugabinga.lsp.clients.lua'
2 +local java = require'bugabinga.lsp.clients.java'
4 +-- FIXME: it is not possible right now to start multiple LSPs perf buffer
2 5 -- NOTE: The order of clients is implicitly priorization.
3 6 -- Put "more specific" clients first
4 7 return {
5 8 lua.nvim_lua_ls,
6 9 lua.lua_ls,
10 + java.jdtls,
11 + java.jdtls_ss,
7 12 require'bugabinga.lsp.clients.json',
13 + require'bugabinga.lsp.clients.archlinux',
14 + require'bugabinga.lsp.clients.asm',
15 + require'bugabinga.lsp.clients.bash',
16 + require'bugabinga.lsp.clients.c',
17 + require'bugabinga.lsp.clients.graphviz',
18 + require'bugabinga.lsp.clients.markdown',
19 + require'bugabinga.lsp.clients.rust',
20 + require'bugabinga.lsp.clients.toml',
21 + require'bugabinga.lsp.clients.vim',
22 + require'bugabinga.lsp.clients.xml',
23 + require'bugabinga.lsp.clients.zig',

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

Added
new file mode 100644
1 +local table = require'std.table'
2 +local project = require'std.project'
4 +local create_shared_config_path = function(base_path, syntax_server)
5 + local os_config
6 + if vim.fn.has('linux') == 1 then
7 + os_config = syntax_server and 'config_linux' or 'config_ss_linux'
8 + elseif vim.fn.has('mac') == 1 then
9 + os_config = syntax_server and 'config_mac' or 'config_ss_mac'
10 + else
11 + os_config = syntax_server and 'config_win' or 'config_ss_win'
12 + end
13 + return vim.fs.joinpath(base_path, os_config)
14 +end
16 +local find_launcher_jar = function(base_path)
17 + local plugins_dir = vim.fs.joinpath(base_path, 'plugins')
18 + local launchers = vim.fn.globpath(plugins_dir, 'org.eclipse.equinox.launcher_*.jar', false, true)
20 + if table.is_empty(launchers) then
21 + vim.error('Could not find jdtls launcher jar in ' .. plugins_dir )
22 + end
24 + -- vim.print('found launcher jars', launchers)
25 + return launchers[1]
26 +end
28 +local create_data_dir = function()
29 + local data_name = vim.fn.sha256(vim.uv.cwd())
30 + local cache = vim.fn.stdpath'cache'
32 + return vim.fs.joinpath(cache, 'jdtls_data', data_name)
33 +end
35 +local create_jdtls_command = function(syntax_server)
36 + local mason_packages_base_path = require'mason-core.package':get_install_path()
37 + local jdtls_package_path = vim.fs.joinpath(mason_packages_base_path, 'jdtls')
38 + local shared_config_path = create_shared_config_path(jdtls_package_path, syntax_server)
39 + local launcher_jar = find_launcher_jar(jdtls_package_path)
40 + local data_dir = create_data_dir()
42 + local ss_option = syntax_server and '-Dsyntaxserver=true' or ''
44 + return {
45 + 'java',
46 + '-Declipse.application=org.eclipse.jdt.ls.core.id1',
47 + '-Dosgi.bundles.defaultStartLevel=4',
48 + '-Declipse.product=org.eclipse.jdt.ls.core.product',
49 + '-Dlog.protocol=true',
50 + '-Dlog.level=INFO',
51 + "-Dosgi.checkConfiguration=true",
52 + "-Dosgi.sharedConfiguration.area=" .. shared_config_path,
53 + "-Dosgi.sharedConfiguration.area.readOnly=true",
54 + "-Dosgi.configuration.cascaded=true",
55 + ss_option,
56 + "-Xms1g",
57 + '-Xmx4g',
58 + '--add-modules=ALL-SYSTEM',
59 + '--add-opens', 'java.base/java.util=ALL-UNNAMED',
60 + '--add-opens', 'java.base/java.lang=ALL-UNNAMED',
61 + '-jar', launcher_jar,
62 + '-data', data_dir,
63 + }
64 +end
66 +local find_jdks = function()
67 + local host = vim.uv.os_gethostname()
68 + local jdk11 = {
69 + name = "JavaSE-11",
70 + }
71 + local jdk17 = {
72 + name = "JavaSE-17",
73 + }
74 + local jdk19 = {
75 + name = "JavaSE-19",
76 + }
78 + if host == 'pop-os' then
79 + jdk11.path = '/usr/lib/jvm/openjdk-11'
80 + jdk17.path = '/usr/lib/jvm/openjdk-17'
81 + jdk19.path = '/usr/lib/jvm/openjdk-19'
82 + else
83 + vim.notify'missing jdk paths in java settings for lsp'
84 + end
86 + return {jdk11, jdk17, jdk20 }
87 +end
89 +local java_settings = {
90 + signatureHelp = { enabled = true },
91 + sources = {
92 + organizeImports = {
93 + starThreshold = 9999,
94 + staticStarThreshold = 9999,
95 + },
96 + },
97 + configuration = { runtimes = find_jdks(), };
100 +local jdtls_lsp_start = function(config, opts)
101 + -- vim.print('jdtls lsp start', config, opts)
102 + require'jdtls'.start_or_attach(config,opts)
103 +end
105 +return {
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 + },

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

Added
new file mode 100644
1 +-- TODO
2 +return {}

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

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

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

Added
new file mode 100644
1 +local project = require'std.project'
3 +local function is_library(path)
4 + local cargo_home = os.getenv 'CARGO_HOME' or util.path.join(vim.env.HOME, '.cargo')
5 + local registry = vim.fs.joinpath(cargo_home, 'registry', 'src')
7 + local rustup_home = os.getenv 'RUSTUP_HOME' or util.path.join(vim.env.HOME, '.rustup')
8 + for _, item in ipairs { toolchains, registry } do
9 + if path:sub(1, #item) == item then
10 + local clients = vim.lsp.get_active_clients { name = 'rust_analyzer' }
11 + return #clients > 0 and clients[#clients].config.root_dir or nil
12 + end
13 + end
14 +end
17 +return {
18 + name = 'rust-analyzer',
19 + command = 'rust-analyzer',
20 + filetypes = 'rust',
21 + root_dir = function(path)
22 + local library_root = is_library(path)
23 + if library_root then return library_root end
24 + return project.find_rust_project_root(path)
25 + end,
26 + capabilities = {
27 + experimental = {
28 + serverStatusNotification = true,
29 + },
30 + },

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

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

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

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

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

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

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

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

neovim/lua/bugabinga/lsp/init.lua

Modified
1 --- TODO: setup neodev + jsonls for neovim plugins ans config
2 --- TODO: setup nvimjdtls + lemminx for java/maven
3 --- TODO: setup marksman + ltex for markdown
4 --- TODO: setup mason for "less important" lsps
5 --- TODO: some snippet plugins seems necessary for some LSPs
1 +local defer = require'std.defer'
7 2 local map = require 'std.keymap'
8 3 local auto = require 'std.auto'
9 4 local ui = require 'bugabinga.ui'
10 5 local table = require 'std.table'
11 6 local ignored = require 'std.ignored'
7 +local user_command = vim.api.nvim_create_user_command
13 8 local lsp_client_configs = require 'bugabinga.lsp.clients'
15 9 local _ = {}
17 11 local token_update = function ( lsp_client )
30 24 --* closures that capture something
33 -local expand_path = function(path)
34 - if vim.fn.executable(path) == 1 then
35 - return vim.fn.exepath(path)
27 +local expand_path = function ( path )
28 + if vim.fn.executable( path ) == 1 then
29 + return vim.fn.exepath( path )
37 31 return path
41 -local expand_command = function(command)
42 - vim.validate{ command = { command, { 'string', 'table' } }}
35 +local expand_command = function ( command )
36 + vim.validate { command = { command, { 'string', 'table' } } }
44 - if type(command) == 'table' then
45 - command[1] = expand_path(command[1])
46 - return command
38 + -- vim.print( 'expanding command', command )
40 + if type( command ) == 'table' then
41 + command[1] = expand_path( command[1] )
42 + return command
49 - return expand_path(command)
45 + return expand_path( command )
52 48 local lsp_start = function ( file_type_event )
49 + -- vim.print("LSP START", file_type_event)
53 51 local match = file_type_event.match
55 53 local matches_to_ignore = ignored.filetypes
54 + -- vim.print('filetypes to ignore', matches_to_ignore)
56 55 if vim.iter( matches_to_ignore ):find( match ) then return end
58 - -- vim.print("LSP START", file_type_event)
60 57 local bufnr = file_type_event.buf
61 58 local buffer_path = vim.api.nvim_buf_get_name( bufnr )
65 62 local potential_client_configs = vim.iter( lsp_client_configs )
66 63 :map( function ( config )
67 64 vim.validate {
68 - config = { config, 'table' },
65 + ['config'] = { config, 'table' },
69 66 ['config.name'] = { config.name, 'string' },
70 67 ['config.filetypes'] = { config.filetypes, { 'string', 'table' } },
71 68 ['config.command'] = { config.command, { 'string', 'table' } },
72 69 ['config.environment'] = { config.environment, 'table', true },
73 70 ['config.root_dir'] = { config.root_dir, 'function', 'string' },
74 - ['config.single_file_support'] = { config.single_file_support, 'boolean' },
71 + ['config.single_file_support'] = { config.single_file_support, 'boolean', true },
75 72 ['config.settings'] = { config.settings, 'table', true },
76 - ['config.workspaces'] = { config.workspaces, 'boolean' },
73 + ['config.workspaces'] = { config.workspaces, 'boolean', true },
77 74 ['config.before_init'] = { config.before_init, 'function', true },
78 75 ['config.init_options'] = { config.init_options, 'table', true },
79 76 ['config.capabilities'] = { config.capabilities, 'table', true },
77 + ['config.custom_start'] = { config.custom_start, 'function', true },
81 79 -- normalize scalar values to its vector alternative for easier processing later on
82 80 -- this mutates the lsp client configs! careful!
83 - config.command = type( config.command ) == 'string' and { expand_command(config.command) } or expand_command(config.command)
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 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
85 87 config.capabilities = config.capabilities or {}
86 88 config.init_options = config.init_options or {}
92 94 end )
93 95 :totable()
95 - -- vim.print("POTENTIAL CLIENTS", #potential_client_configs)
97 + -- vim.print("POTENTIAL CLIENTS", vim.iter(potential_client_configs):map(function(config) return { name = config.name, command = config.command } end):totable())
97 99 -- find clients, that returns some root_dir for this buffer
98 100 local config = vim.iter( potential_client_configs ):find(
109 111 if not config then
110 - vim.print('FOUND NO LSP CLIENT FOR', buffer_path)
112 + -- vim.print('FOUND NO LSP CLIENT FOR', buffer_path)
111 113 return
114 116 assert( config, 'a matching LSP client config shoud have been found by now!' )
116 - local root_dir = type(config.root_dir) == "string" and config.root_dir or config.root_dir( buffer_path )
118 + local root_dir = type( config.root_dir ) == 'string' and config.root_dir or config.root_dir( buffer_path )
117 119 local capabilities = vim.lsp.protocol.make_client_capabilities()
118 - capabilities = table.extend("force", capabilities, config.capabilities)
120 + capabilities = table.extend( 'force', capabilities, config.capabilities )
120 122 local start_config = {
121 123 cmd = config.command,
141 143 root_dir = root_dir,
144 - local client_id = vim.lsp.start( start_config, {
146 + local lsp_starter = config.custom_start or vim.lsp.start
148 + local client_id = lsp_starter( start_config, {
145 149 bufnr = bufnr,
146 150 -- TODO: reuse if workspaces
147 151 -- local supported = vim.tbl_get(client, 'server_capabilities', 'workspace', 'workspaceFolders', 'supported')
148 152 -- reuse_client = function(existing_client, config)end,
151 - vim.print("ATTACHING LSP CLIENT", client_id)
155 + -- vim.print("ATTACHING LSP CLIENT", client_id)
154 158 local old_formatexpr
203 207 if client.server_capabilities.documentHighlightProvider then
208 + -- the timer has application lifetime. no need to close
209 + 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)
204 213 auto 'document_highlight' {
206 215 description = 'Highlight symbol under cursor on hold',
207 216 events = 'CursorHold',
208 - pattern = '<buffer>',
209 - command = vim.lsp.buf.document_highlight,
217 + buffer = bufnr,
218 + command = debounced_highlight,
211 - --TODO: debounce cursormoved events
213 221 description = 'Remove highlight from symbol under cursor on move',
214 222 events = { 'CursorMoved', 'InsertEnter' },
215 - pattern = '<buffer>',
216 - command = vim.lsp.buf.clear_references,
223 + buffer = bufnr,
224 + command = debounced_clear,
233 241 map.normal {
234 242 name = 'Format current buffer',
235 243 category = 'lsp',
236 - keys = '<c-F>',
244 + keys = '<c-s>',
237 245 command = vim.lsp.buf.format,
240 248 map.normal {
241 249 name = 'Show hover documentation above cursor.',
242 250 category = 'lsp',
243 - keys = '<c-q>',
251 + keys = '<c-0>',
244 252 command = vim.lsp.buf.hover,
298 306 map.normal {
299 307 name = 'Rename symbol under cursor.',
300 308 category = 'lsp',
301 - keys = '<c-R>',
309 + keys = '<c-9>',
302 310 command = vim.lsp.buf.rename,
305 313 map.normal {
306 314 name = 'Show signature help under cursor.',
307 315 category = 'lsp',
308 - keys = '<c-7>',
316 + keys = '<c-s-0>',
309 317 command = vim.lsp.buf.signature_help,
312 320 map.normal {
313 321 name = 'Show signature help under cursor.',
314 322 category = 'telescope',
315 - keys = '<c-7><c-7>',
323 + keys = '<c-s-0><c-s-0>',
316 324 command = '<cmd>Telescope lsp_signature_help<cr>',
363 371 local lsp_info = function ( command )
364 372 local all_or_current = command.args and command.args == 'all' and {} or { bufnr = 0 }
365 - local active_clients = vim.lsp.get_clients( all_or_current )
373 + local active_clients = vim.lsp.get_active_clients( all_or_current )
367 375 local infos = vim.iter( active_clients )
368 376 :map( function ( client )
395 403 ui.show_tree( active_clients )
398 -vim.api.nvim_create_user_command( 'LspInfo',
399 - lsp_info,
400 - {
401 - nargs = '?',
402 - complete = function () return { 'all' } end,
403 - desc = 'Shows basic information about running LSP clients.',
404 - } )
406 +user_command( 'LspInfo', lsp_info, {
407 + nargs = '?',
408 + complete = function () return { 'all' } end,
409 + desc = 'Shows basic information about running LSP clients.',
410 +} )
412 +user_command( 'LspInfoExtended', lsp_info_extended, {
413 + nargs = '?',
414 + complete = function () return { 'all' } end,
415 + desc = 'Shows detailed information about running LSP clients.',
416 +} )
406 -vim.api.nvim_create_user_command( 'LspInfoExtended',
407 - lsp_info_extended,
408 - {
409 - nargs = '?',
410 - complete = function () return { 'all' } end,
411 - desc = 'Shows detailed information about running LSP clients.',
412 - } )
413 418 return setmetatable( _, {} )

neovim/lua/bugabinga/nugu/init.lua

Modified
1 +---@diagnostic disable: undefined-global
1 2 local palette = require 'bugabinga.nugu.palette'
2 3 local lush = require 'lush'
3 4 local hsl = lush.hsluv
169 170 DiagnosticSignHint { DiagnosticHint },
170 171 DiagnosticSignOk { DiagnosticOk },
172 - LspReferenceText { bg = content_unfocus },
173 + LspReferenceText { fg = content_focus, bg = content_unfocus },
173 174 LspReferenceRead { LspReferenceText },
174 175 LspReferenceWrite { LspReferenceText },
176 177 -- hlargs.nvim
177 - Hlargs { fg = ui_important_local, gui = 'bold underdotted' },
178 + Hlargs { fg = ui_important_local },
179 180 -- Tree-Sitter syntax groups.
194 195 -- For more information see https://github.com/rktjmp/lush.nvim/issues/109
196 - -- sym"@text.literal" { }, -- Comment
197 - -- sym"@text.reference" { }, -- Identifier
198 - -- sym"@text.title" { }, -- Title
199 - -- sym"@text.uri" { }, -- Underlined
200 - -- sym"@text.underline" { }, -- Underlined
201 - -- sym"@text.todo" { }, -- Todo
202 - -- sym"@comment" { }, -- Comment
203 - -- sym"@punctuation" { }, -- Delimiter
204 - -- sym"@constant" { }, -- Constant
205 - -- sym"@constant.builtin" { }, -- Special
206 - -- sym"@constant.macro" { }, -- Define
207 - -- sym"@define" { }, -- Define
208 - -- sym"@macro" { }, -- Macro
209 - -- sym"@string" { }, -- String
210 - -- sym"@string.escape" { }, -- SpecialChar
211 - -- sym"@string.special" { }, -- SpecialChar
212 - -- sym"@character" { }, -- Character
213 - -- sym"@character.special" { }, -- SpecialChar
214 - -- sym"@number" { }, -- Number
215 - -- sym"@boolean" { }, -- Boolean
216 - -- sym"@float" { }, -- Float
217 - -- sym"@function" { }, -- Function
218 - -- sym"@function.builtin" { }, -- Special
219 - -- sym"@function.macro" { }, -- Macro
220 - -- sym"@parameter" { }, -- Identifier
221 - -- sym"@method" { }, -- Function
222 - -- sym"@field" { }, -- Identifier
223 - -- sym"@property" { }, -- Identifier
224 - -- sym"@constructor" { }, -- Special
225 - -- sym"@conditional" { }, -- Conditional
226 - -- sym"@repeat" { }, -- Repeat
227 - -- sym"@label" { }, -- Label
228 - -- sym"@operator" { }, -- Operator
229 - -- sym"@keyword" { }, -- Keyword
230 - -- sym"@exception" { }, -- Exception
231 - -- sym"@variable" { }, -- Identifier
232 - -- sym"@type" { }, -- Type
233 - -- sym"@type.definition" { }, -- Typedef
234 - -- sym"@storageclass" { }, -- StorageClass
235 - -- sym"@structure" { }, -- Structure
236 - -- sym"@namespace" { }, -- Identifier
237 - -- sym"@include" { }, -- Include
238 - -- sym"@preproc" { }, -- PreProc
239 - -- sym"@debug" { }, -- Debug
240 - -- sym"@tag" { }, -- Tag
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
242 243 -- lazy.nvim
243 244 LazyButton { NormalFloat, sp = NormalFloat.fg, gui = 'bold' },
434 435 GitSignsDeleteVirtLn { GitSignsDelete },
435 436 GitSignsDeleteVirtLnInLine { DiffText },
436 437 GitSignsVirtLnum { fg = LineNr.fg },
439 + MultiCursorMain { fg = content_important_local, bg = content_unfocus, gui = "bold"}

neovim/lua/bugabinga/plugins/mason.lua

Modified
1 1 return {
2 2 "williamboman/mason.nvim",
3 + -- needs to be loaded early, so that LSP can find programs in PATH
4 + lazy = false,
3 5 cmd = { 'Mason', 'MasonUpdate', 'MasonInstall', 'MasonUninstall', 'MasonUninstallAll', 'MasonLog' },
4 6 opts = {
5 7 ui = {

neovim/lua/bugabinga/plugins/multicursors.lua

Added
new file mode 100644
1 +return {
2 + 'smoka7/multicursors.nvim',
3 + event = 'VeryLazy',
4 + dependencies = {
5 + 'nvim-treesitter/nvim-treesitter',
6 + 'anuvyklack/hydra.nvim',
7 + },
8 + opts = {
9 + hint_config = {
10 + border = vim.g.border_style,
11 + },
12 + generate_hints = {
13 + normal = true,
14 + insert = false,
15 + extend = false,
16 + }
17 + },
18 + cmd = { 'MCstart', 'MCvisual', 'MCclear', 'MCpattern', 'MCvisualPattern', 'MCunderCursor' },
19 + keys = {
20 + {
21 + mode = { 'v', 'n' },
22 + '<c-n>',
23 + '<cmd>MCstart<cr>',
24 + desc = 'Create a selection for selected text or word under the cursor',
25 + },
26 + },

neovim/lua/bugabinga/plugins/nvim-jdtls.lua

Added
new file mode 100644
1 +return {
2 + 'bugabinga/nvim-jdtls',
3 + ft = { 'java' },
4 +}

neovim/lua/bugabinga/plugins/telescope.lua

Modified
1 1 local map = require 'std.keymap'
3 -require'bugabinga.health'.add_dependency
3 +require 'bugabinga.health'.add_dependency
5 - name = 'ripgrep',
6 - name_of_executable = 'rg'
7 -}
8 -{
9 - name = 'find-fd',
10 - name_of_executable = 'fd'
5 + name = 'ripgrep',
6 + name_of_executable = 'rg'
8 + {
9 + name = 'find-fd',
10 + name_of_executable = 'fd'
11 + }
13 13 return {
14 - 'nvim-telescope/telescope.nvim',
15 - branch = '0.1.x',
16 - cmd = 'Telescope',
17 - keys = { '<C-p><C-n>', '<C-e>', '<C-p><C-b>', '<C-p><C-g>', '<C-p><C-s>', '<C-p><C-k>', '<C-p><C-p>', '<C-p>', '<F1>' },
18 - dependencies = {
19 - 'nvim-lua/plenary.nvim',
20 - 'nvim-tree/nvim-web-devicons',
21 - 'nvim-telescope/telescope-symbols.nvim',
22 - },
23 - config = function()
24 - local telescope = require 'telescope'
25 - local builtin = require 'telescope.builtin'
26 - local actions = require 'telescope.actions'
27 - local themes = require 'telescope.themes'
28 - local ivy = themes.get_ivy { hidden = true, layout_config = { preview_width = 0.69 } }
29 - local dropdown = themes.get_dropdown { layout_config = { width = 0.69 } }
30 - local cursor = themes.get_cursor { layout_config = { preview_width = 0.42, width = 0.69 } }
14 + 'nvim-telescope/telescope.nvim',
15 + branch = '0.1.x',
16 + cmd = 'Telescope',
17 + event = 'VeryLazy',
18 + dependencies = {
19 + 'nvim-lua/plenary.nvim',
20 + 'nvim-tree/nvim-web-devicons',
21 + 'nvim-telescope/telescope-symbols.nvim',
22 + 'nvim-telescope/telescope-ui-select.nvim',
23 + 'jvgrootveld/telescope-zoxide',
24 + },
25 + config = function ()
26 + local telescope = require 'telescope'
27 + local builtin = require 'telescope.builtin'
28 + local actions = require 'telescope.actions'
29 + local themes = require 'telescope.themes'
30 + local ivy = themes.get_ivy { hidden = true, layout_config = { preview_width = 0.69 } }
31 + local dropdown = themes.get_dropdown { layout_config = { width = 0.69 } }
32 + local cursor = themes.get_cursor { layout_config = { preview_width = 0.42, width = 0.69 } }
32 - telescope.setup {
33 - defaults = {
34 - path_display = { 'truncate' },
35 - sorting_strategy = 'ascending',
36 - layout_config = {
37 - horizontal = { prompt_position = 'bottom', preview_width = 0.69 },
38 - vertical = { mirror = false },
39 - width = 0.69,
40 - height = 0.42,
41 - preview_cutoff = 124,
42 - },
43 - mappings = {
44 - i = {
45 - ['<C-j>'] = actions.cycle_history_next,
46 - ['<C-k>'] = actions.cycle_history_prev,
47 - ['<C-n>'] = actions.move_selection_next,
48 - ['<C-p>'] = actions.move_selection_previous,
49 - },
50 - n = { q = actions.close },
51 - },
52 - },
53 - }
34 + telescope.setup {
35 + defaults = {
36 + path_display = { 'truncate' },
37 + sorting_strategy = 'ascending',
38 + layout_config = {
39 + horizontal = { prompt_position = 'bottom', preview_width = 0.69 },
40 + vertical = { mirror = false },
41 + width = 0.69,
42 + height = 0.42,
43 + preview_cutoff = 124,
44 + },
45 + mappings = {
46 + i = {
47 + ['<C-j>'] = actions.cycle_history_next,
48 + ['<C-k>'] = actions.cycle_history_prev,
49 + ['<C-n>'] = actions.move_selection_next,
50 + ['<C-p>'] = actions.move_selection_previous,
51 + },
52 + n = { q = actions.close },
53 + },
54 + },
55 + extensions = {
56 + ['ui-select'] = { cursor },
57 + zoxide = {
58 + ivy,
59 + prompt_title = 'Navigate deez nuts!',
60 + },
61 + },
62 + }
55 - map.normal.visual.terminal {
56 - name = 'Search help files',
57 - category = 'help',
58 - keys = '<F1>',
59 - command = function() builtin.help_tags(dropdown) end,
60 - }
64 + telescope.load_extension 'ui-select'
65 + telescope.load_extension 'zoxide'
62 - map.normal {
63 - name = 'Open global search...',
64 - category = 'plugins',
65 - keys = '<C-p>',
66 - command = function() builtin.builtin() end,
67 - }
67 + map.normal {
68 + name = 'Switch to recently used foleders',
69 + category = 'navigation',
70 + keys = '<c-z>',
71 + command = telescope.extensions.zoxide.list,
72 + }
69 - map.normal {
70 - name = 'Open search for all files...',
71 - category = 'search',
72 - keys = '<C-p><C-p>',
73 - command = function() builtin.find_files(ivy) end,
74 - }
74 + map.normal.visual.terminal {
75 + name = 'Search help files',
76 + category = 'help',
77 + keys = '<F1>',
78 + command = function () builtin.help_tags( dropdown ) end,
79 + }
76 - map.normal {
77 - name = 'Open search for keymaps...',
78 - category = 'search',
79 - keys = '<C-p><C-k>',
80 - command = function() builtin.keymaps(dropdown) end,
81 - }
81 + map.normal {
82 + name = 'Open search for commands...',
83 + category = 'plugins',
84 + keys = '<C-p>',
85 + command = function () builtin.commands() end,
86 + }
83 - map.normal {
84 - name = 'Open search for symbols...',
85 - category = 'search',
86 - keys = '<C-p><C-s>',
87 - command = function() builtin.symbols(cursor) end,
88 - }
88 + map.normal {
89 + name = 'Open search for all files...',
90 + category = 'search',
91 + keys = '<C-p><C-p>',
92 + command = function () builtin.find_files( ivy ) end,
93 + }
90 - map.normal {
91 - name = 'Open search for all file contents...',
92 - category = 'search',
93 - keys = '<C-p><C-g>',
94 - command = function() builtin.live_grep(ivy) end,
95 - }
95 + map.normal {
96 + name = 'Open search for keymaps...',
97 + category = 'search',
98 + keys = '<C-p><C-k>',
99 + command = function () builtin.keymaps( dropdown ) end,
97 - map.normal {
98 - name = 'Open search for current buffer content...',
99 - category = 'search',
100 - keys = '<C-p><C-b>',
101 - command = function() builtin.current_buffer_fuzzy_find(ivy) end,
102 - }
102 + map.normal {
103 + name = 'Open search for symbols...',
104 + category = 'search',
105 + keys = '<C-p><C-s>',
106 + command = function () builtin.symbols( cursor ) end,
104 - map.normal {
105 - name = 'Open search for buffers...',
106 - category = 'search',
107 - keys = '<C-e>',
108 - command = function() builtin.buffers(cursor) end,
109 - }
109 + map.normal {
110 + name = 'Open search for all file contents...',
111 + category = 'search',
112 + keys = '<C-p><C-g>',
113 + command = function () builtin.live_grep( ivy ) end,
111 - end,
116 + map.normal {
117 + name = 'Open search for current buffer content...',
118 + category = 'search',
119 + keys = '<C-p><C-b>',
120 + command = function () builtin.current_buffer_fuzzy_find( ivy ) end,
123 + map.normal {
124 + name = 'Open search for buffers...',
125 + category = 'search',
126 + keys = '<C-e>',
127 + command = function () builtin.buffers( cursor ) end,
129 + end,

neovim/lua/bugabinga/plugins/toggleterm.lua

Modified
1 -local map = require'std.keymap'
2 -local auto = require'std.auto'
1 +local map = require 'std.keymap'
2 +local auto = require 'std.auto'
4 -require'bugabinga.health'.add_dependency
4 +require 'bugabinga.health'.add_dependency
6 - name_of_executable = 'gitui',
7 -}
8 -{
9 - name_of_executable = 'mdcat',
12 - name_of_executable = 'dot'
6 + name_of_executable = 'gitui',
8 + {
9 + name_of_executable = 'mdcat',
10 + }
11 + {
12 + name_of_executable = 'dot'
13 + }
15 -return {
16 - "akinsho/toggleterm.nvim",
17 - keys = {
18 - '<F7>',
19 - '<F8>',
20 - '<F9>',
21 - '<F10>',
22 - },
23 - cmd = {
24 - "ToggleTerm",
25 - "TermExec",
26 - 'Gitui',
27 - 'Mdcat',
28 - 'Graphviz',
29 - 'Graphviz',
30 - },
31 - opts = {
32 - open_mapping = '<F7>',
33 - direction = "float",
34 - float_opts = {
35 - border = vim.g.border_style,
36 - winblend = 10,
37 - },
38 - size = function(term)
39 - if term.direction == "horizontal" then
40 - return 18
41 - elseif term.direction == "vertical" then
42 - return vim.o.columns * 0.42
43 - end
44 - end,
45 - },
46 - config = function(_, opts)
47 - local toggleterm = require'toggleterm'
48 - toggleterm.setup(opts)
15 +return {
16 + 'akinsho/toggleterm.nvim',
17 + keys = {
18 + '<F7>',
19 + '<F8>',
20 + '<F9>',
21 + '<F10>',
22 + },
23 + cmd = {
24 + 'ToggleTerm',
25 + 'TermExec',
26 + 'Gitui',
27 + 'Mdcat',
28 + 'Graphviz',
29 + 'Graphviz',
30 + },
31 + opts = {
32 + open_mapping = '<F7>',
33 + direction = 'float',
34 + float_opts = {
35 + border = vim.g.border_style,
36 + winblend = 10,
37 + },
38 + size = function ( term )
39 + if term.direction == 'horizontal' then
40 + return 18
41 + elseif term.direction == 'vertical' then
42 + return vim.o.columns * 0.42
43 + end
44 + end,
45 + },
46 + config = function ( _, opts )
47 + local toggleterm = require 'toggleterm'
48 + toggleterm.setup( opts )
50 - local set_terminal_keymaps = function()
51 - local local_to_buffer = { buffer = 0 }
52 - map.terminal {
53 - name = 'Quit insert mode',
54 - category = 'terminal',
55 - keys = '<esc>',
56 - options = local_to_buffer,
57 - command = [[ <C-\><C-n> ]],
58 - }
59 - end
50 + local set_terminal_keymaps = function ()
51 + local local_to_buffer = { buffer = 0 }
52 + map.terminal {
53 + name = 'Quit insert mode',
54 + category = 'terminal',
55 + keys = '<esc>',
56 + options = local_to_buffer,
57 + command = [[ <C-\><C-n> ]],
58 + }
59 + end
61 - auto'normalize_terminal_windows'{
62 - description = 'Make terminal windows behave more normally.',
63 - events = 'TermOpen',
64 - pattern = 'term://*',
65 - command = set_terminal_keymaps,
66 - }
61 + auto 'normalize_terminal_windows' {
62 + description = 'Make terminal windows behave more normally.',
63 + events = 'TermOpen',
64 + pattern = 'term://*',
65 + command = set_terminal_keymaps,
66 + }
68 - local Terminal = require'toggleterm.terminal'.Terminal
68 + map.normal {
69 + name = 'Open vertical Terminal',
70 + category = 'terminal',
71 + keys = '<F8>',
72 + command = '<CMD>exe v:count1 . "ToggleTerm size=60 direction=vertical"<CR>'
73 + }
70 - --[ GITUI ]
75 + map.normal {
76 + name = 'Open horizontal Terminal',
77 + category = 'terminal',
78 + keys = '<F9>',
79 + command = '<CMD>exe v:count1 . "ToggleTerm size=20 direction=horizontal"<CR>'
80 + }
72 - local gitui = Terminal:new{
73 - hidden = true,
74 - cmd = 'gitui',
75 - dir = 'git_dir',
76 - direction = 'tab',
77 - }
82 + local Terminal = require 'toggleterm.terminal'.Terminal
79 - _G.Gitui = function() gitui:toggle() end
84 + --[ GITUI ]
81 - map.normal.terminal.insert {
82 - name = 'Toggle gitui terminal in tab',
83 - category = 'terminal',
84 - keys = '<F8>',
85 - command = Gitui,
86 - }
86 + local gitui = Terminal:new {
87 + hidden = true,
88 + cmd = 'gitui',
89 + dir = 'git_dir',
90 + direction = 'tab',
91 + }
88 - vim.cmd[[ command! Gitui lua Gitui() ]]
93 + _G.Gitui = function () gitui:toggle() end
90 - --[ MDCAT ]
95 + map.normal.terminal.insert {
96 + name = 'Toggle gitui terminal in tab',
97 + category = 'terminal',
98 + keys = '<F10>',
99 + command = Gitui,
92 - local mdcat = Terminal:new {
93 - hidden = true,
94 - direction = 'vertical',
95 - }
102 + vim.cmd [[ command! Gitui lua Gitui() ]]
97 - _G.Mdcat = function()
98 - local window = vim.api.nvim_get_current_win()
99 - local current_file = vim.api.nvim_buf_get_name(0)
100 - mdcat.cmd = 'watch ' .. current_file .. ' { clear; mdcat ' .. current_file ..' }'
101 - mdcat:toggle()
102 - vim.api.nvim_set_current_win(window)
103 - end
104 + --[ MDCAT ]
105 - map.normal.terminal.insert {
106 - name = 'Toggle markdown preview via mdcat',
107 - category = 'terminal',
108 - keys = '<F9>',
109 - command = Mdcat,
110 - }
106 + local mdcat = Terminal:new {
107 + hidden = true,
108 + direction = 'vertical',
109 + cmd = '',
112 - vim.cmd [[ command! Mdcat lua Mdcat() ]]
112 + _G.Mdcat = function ()
113 + local window = vim.api.nvim_get_current_win()
114 + local current_file = vim.api.nvim_buf_get_name( 0 )
115 + mdcat.cmd = 'watch ' .. current_file .. ' { clear; mdcat ' .. current_file .. ' }'
116 + mdcat:toggle()
117 + vim.api.nvim_set_current_win( window )
118 + end
114 - -- [ GRAPHVIZ ]
120 + vim.cmd [[ command! Mdcat lua Mdcat() ]]
116 - local graphviz = Terminal:new {
117 - hidden = true,
118 - direction = 'vertical',
119 - }
122 + -- [ GRAPHVIZ ]
121 - _G.Graphviz = function()
122 - local window = vim.api.nvim_get_current_win()
123 - local current_file = vim.api.nvim_buf_get_name(0)
124 - graphviz.cmd = 'watch ' .. current_file .. ' { clear; dot -O -Tpng ' .. current_file .. ' ; viu --blocks ' .. current_file .. '.png }'
125 - graphviz:toggle()
126 - vim.api.nvim_set_current_win(window)
127 - end
124 + local graphviz = Terminal:new {
125 + hidden = true,
126 + direction = 'vertical',
127 + cmd = '',
129 - map.normal.terminal.insert {
130 - name = 'Toggle graphviz preview via viu',
131 - category = 'terminal',
132 - keys = '<F10>',
133 - command = Graphviz,
134 - }
130 + _G.Graphviz = function ()
131 + local window = vim.api.nvim_get_current_win()
132 + local current_file = vim.api.nvim_buf_get_name( 0 )
133 + graphviz.cmd = 'watch ' ..
134 + current_file .. ' { clear; dot -O -Tpng ' .. current_file .. ' ; viu --blocks ' .. current_file .. '.png }'
135 + graphviz:toggle()
136 + vim.api.nvim_set_current_win( window )
137 + end
136 - vim.cmd [[ command! Graphviz lua Graphviz() ]]
137 - end
139 + vim.cmd [[ command! Graphviz lua Graphviz() ]]
140 + end

neovim/lua/std/auto.lua

Modified
18 18 vim.api.nvim_create_autocmd(autocommand.events, {
19 19 desc = autocommand.description,
20 20 group = group,
21 + buffer = autocommand.buffer,
21 22 pattern = autocommand.pattern,
22 23 command = command,
23 24 callback = callback,

neovim/lua/std/defer.lua

Added
new file mode 100644
1 +-- taken from https://gist.github.com/runiq/31aa5c4bf00f8e0843cd267880117201
3 +local _ = {}
5 +---Validates args for `throttle()` and `debounce()`.
6 +local function td_validate(fn, ms)
7 + vim.validate{
8 + fn = { fn, 'f' },
9 + ms = {
10 + ms,
11 + function(ms)
12 + return type(ms) == 'number' and ms > 0
13 + end,
14 + "number > 0",
15 + },
16 + }
17 +end
19 +--- Throttles a function on the leading edge. Automatically `schedule_wrap()`s.
20 +---
21 +--@param fn (function) Function to throttle
22 +--@param timeout (number) Timeout in ms
23 +--@returns (function, timer) throttled function and timer. Remember to call
24 +---`timer:close()` at the end or you will leak memory!
25 +function _.throttle_leading(fn, ms)
26 + td_validate(fn, ms)
27 + local timer = vim.loop.new_timer()
28 + local running = false
30 + local function wrapped_fn(...)
31 + if not running then
32 + timer:start(ms, 0, function()
33 + running = false
34 + end)
35 + running = true
36 + pcall(vim.schedule_wrap(fn), select(1, ...))
37 + end
38 + end
39 + return wrapped_fn, timer
40 +end
42 +--- Throttles a function on the trailing edge. Automatically
43 +--- `schedule_wrap()`s.
44 +---
45 +--@param fn (function) Function to throttle
46 +--@param timeout (number) Timeout in ms
47 +--@param last (boolean, optional) Whether to use the arguments of the last
48 +---call to `fn` within the timeframe. Default: Use arguments of the first call.
49 +--@returns (function, timer) Throttled function and timer. Remember to call
50 +---`timer:close()` at the end or you will leak memory!
51 +function _.throttle_trailing(fn, ms, last)
52 + td_validate(fn, ms)
53 + local timer = vim.loop.new_timer()
54 + local running = false
56 + local wrapped_fn
57 + if not last then
58 + function wrapped_fn(...)
59 + if not running then
60 + local argv = {...}
61 + local argc = select('#', ...)
63 + timer:start(ms, 0, function()
64 + running = false
65 + pcall(vim.schedule_wrap(fn), unpack(argv, 1, argc))
66 + end)
67 + running = true
68 + end
69 + end
70 + else
71 + local argv, argc
72 + function wrapped_fn(...)
73 + argv = {...}
74 + argc = select('#', ...)
76 + if not running then
77 + timer:start(ms, 0, function()
78 + running = false
79 + pcall(vim.schedule_wrap(fn), unpack(argv, 1, argc))
80 + end)
81 + running = true
82 + end
83 + end
84 + end
85 + return wrapped_fn, timer
86 +end
88 +--- Debounces a function on the leading edge. Automatically `schedule_wrap()`s.
89 +---
90 +--@param fn (function) Function to debounce
91 +--@param timeout (number) Timeout in ms
92 +--@returns (function, timer) Debounced function and timer. Remember to call
93 +---`timer:close()` at the end or you will leak memory!
94 +function _.debounce_leading(fn, ms)
95 + td_validate(fn, ms)
96 + local timer = vim.loop.new_timer()
97 + local running = false
99 + local function wrapped_fn(...)
100 + timer:start(ms, 0, function()
101 + running = false
102 + end)
104 + if not running then
105 + running = true
106 + pcall(vim.schedule_wrap(fn), select(1, ...))
107 + end
108 + end
109 + return wrapped_fn, timer
110 +end
112 +--- Debounces a function on the trailing edge. Automatically
113 +--- `schedule_wrap()`s.
114 +---
115 +--@param fn (function) Function to debounce
116 +--@param timeout (number) Timeout in ms
117 +--@param first (boolean, optional) Whether to use the arguments of the first
118 +---call to `fn` within the timeframe. Default: Use arguments of the last call.
119 +--@returns (function, timer) Debounced function and timer. Remember to call
120 +---`timer:close()` at the end or you will leak memory!
121 +function _.debounce_trailing(fn, ms, first)
122 + td_validate(fn, ms)
123 + local timer = vim.loop.new_timer()
124 + local wrapped_fn
126 + if not first then
127 + function wrapped_fn(...)
128 + local argv = {...}
129 + local argc = select('#', ...)
131 + timer:start(ms, 0, function()
132 + pcall(vim.schedule_wrap(fn), unpack(argv, 1, argc))
133 + end)
134 + end
135 + else
136 + local argv, argc
137 + function wrapped_fn(...)
138 + argv = argv or {...}
139 + argc = argc or select('#', ...)
141 + timer:start(ms, 0, function()
142 + pcall(vim.schedule_wrap(fn), unpack(argv, 1, argc))
143 + end)
144 + end
145 + end
146 + return wrapped_fn, timer
147 +end
149 +--- Test deferment methods (`{throttle,debounce}_{leading,trailing}()`).
150 +---
151 +--@param bouncer (string) Bouncer function to test
152 +--@param ms (number, optional) Timeout in ms, default 2000.
153 +--@param firstlast (bool, optional) Whether to use the 'other' fn call
154 +---strategy.
155 +function _.test_defer(bouncer, ms, firstlast)
156 + local bouncers = {
157 + tl = _.throttle_leading,
158 + tt = _.throttle_trailing,
159 + dl = _.debounce_leading,
160 + dt = _.debounce_trailing,
163 + local timeout = ms or 2000
165 + local bounced = bouncers[bouncer](
166 + function(i) vim.cmd('echom "' .. bouncer .. ': ' .. i .. '"') end,
167 + timeout,
168 + firstlast
171 + for i, _ in ipairs{1,2,3,4,5} do
172 + bounced(i)
173 + vim.schedule(function () vim.cmd('echom ' .. i) end)
174 + vim.fn.call("wait", {1000, "v:false"})
175 + end
176 +end
178 +return _

neovim/lua/std/icon.lua

Modified
38 38 lazy = '󰄻',
39 39 global = '󱥔',
40 40 ['local'] = '󱥕',
41 - space = '∸',
41 + space = '⋅',
42 42 eol = '↴',
43 43 tab = '󰌒',
44 44 trail = '•',

neovim/lua/std/ignored.lua

Modified
11 11 'toggleterm',
12 12 'lazy',
13 13 'oil',
14 + 'spectre_panel',
16 17 local buftypes = {

neovim/lua/std/project.lua

Modified
99 99 -- stop if we reached the user defined stop instead of the file system root
100 100 local current_path = path
101 101 while current_path ~= stop do
102 - if loop_count > MAX_TRAVERSAL_COUNT then error(( 'searching for markers reached the max traversal count for path %s !' ):format(path)) end
102 + if loop_count > MAX_TRAVERSAL_COUNT then
103 + vim.notify(( 'searching for markers reached the max traversal count for path %s !' ):format(path))
104 + break
105 + end
104 107 local score = {
105 108 path = current_path,
150 153 --- 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.
154 +---@param path string? path to start searching from. If `nil`, then path of current buffer is used.
151 155 ---@param markers table<string, number>? list of markers. a marker is a table with `name` and `weight` key. `name` can be a file or directory name, that indicates, that if a file/folder with that name exists in a directory, that directory is likely to be a project root. `weight` is a means to express confidence in that likelihood. Values should be between 1 and 3. Internally, there are some project-agnostic markers defined (e.g. README, LICENSE, .git, ...) that will be merged with `custom_markers`.
153 157 ---@return string? # The project root of the current buffer, or `nil`, if none could be determined.
155 -local function find_project_root(markers)
159 +local function find_project_root(path, markers)
156 160 -- define some language-independent markers
157 161 local default_markers = {
158 162 { name = '.git', weight = 1 },
172 176 { name = 'flake.nix', weight = 1 },
175 - return find_root(nil, join(default_markers, markers))
179 + return find_root(path, join(default_markers, markers))
178 -local function find_vcs_project_root()
179 - return find_project_root{}
182 +local function find_vcs_project_root(path)
183 + return find_project_root(path, {})
182 -local function find_java_project_root()
186 +local function find_java_project_root(path)
183 187 local java_markers = {
184 188 { name = '.idea', weight = 2 },
185 189 { name = '.classpath', weight = 2 },
196 200 { name = 'gradlew', weight = 3 },
197 201 { name = 'gradlew.bat', weight = 3 },
199 - return find_root(nil, java_markers)
203 + return find_root(path, java_markers)
202 206 -- TODO: how to get a marker for luarocks stuff?
215 219 {name = 'lua', weight = 1},
218 -local find_lua_project_root = function()
219 - return find_root(nil, lua_markers)
222 +local find_lua_project_root = function(path)
223 + return find_root(path, lua_markers)
222 -local find_lua_nvim_project_root = function()
223 - return find_root(nil, nvim_lua_markers)
226 +local find_lua_nvim_project_root = function(path)
227 + return find_root(path, nvim_lua_markers)
228 +end
230 +local zig_markers = {
231 + { name = 'build.zig', weight = 3 },
232 + { name = 'zls.build.json', weight = 3 },
233 + { name = 'zig-cache', weight = 1 },
234 + { name = 'zig-out', weight = 1 },
237 +local find_zig_project_root = function(path)
238 + return find_root(path, zig_markers)
239 +end
241 +local find_rust_project_root = function(path)
242 + local markers = {
243 + { name = 'Cargo.toml', weight = 3 },
245 + local cargo_crate_dir = find_root(path, markers)
246 + if cargo_crate_dir == nil then return nil end
248 + local cmd = {
249 + 'cargo',
250 + 'metadata',
251 + '--no-deps',
252 + '--format-version',
253 + '1',
254 + '--manifest-path',
255 + vim.fs.joinpath(cargo_crate_dir, 'Cargo.toml'),
258 + local result = vim.system(cmd, { text = true }):wait()
259 + local cargo_workspace_root
261 + if result.code == 0 then
262 + local json = vim.json.decode(result.stdout)
263 + if json['workspace_root'] then
264 + cargo_workspace_root = vim.fs.normalize(json['workspace_root'])
265 + end
266 + end
268 + return cargo_workspace_root or cargo_crate_dir
226 271 return {
227 272 find_root = find_root,
273 + find_project_root = find_project_root,
228 274 find_vcs_project_root = find_vcs_project_root,
229 275 find_java_project_root = find_java_project_root,
230 276 find_lua_project_root = find_lua_project_root,
231 277 find_lua_nvim_project_root = find_lua_nvim_project_root,
278 + find_zig_project_root = find_zig_project_root,
279 + find_rust_project_root = find_rust_project_root,