repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim: json schema store

ac0d0c30c92272a83288a07e54b7867cd20ca953

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (6)

neovim/lazy-lock.json

Modified
3 3 "Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" },
4 4 "better-escape.nvim": { "branch": "master", "commit": "7031dc734add47bb71c010e0551829fa5799375f" },
5 5 "cmp-omni": { "branch": "main", "commit": "9436e6cdd7c5dfa24a99a60d9280b24dbdea3649" },
6 - "diffview.nvim": { "branch": "main", "commit": "500d8b2013812e05ab87db83a8d22319986519f2" },
6 + "diffview.nvim": { "branch": "main", "commit": "db97e667e03294bfa9f15e544e78f3082247bf79" },
7 7 "dressing.nvim": { "branch": "master", "commit": "c0b67f3e2950adc07b555d3e73e38275b4a585ce" },
8 8 "flash.nvim": { "branch": "main", "commit": "e5a7bd96d0bb7e0806bfc18adea5ab148165bd62" },
9 9 "gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" },
28 28 "nvim-neoclip.lua": { "branch": "main", "commit": "4e406ae0f759262518731538f2585abb9d269bac" },
29 29 "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" },
30 30 "nvim-surround": { "branch": "main", "commit": "0d6882635817a2677749a330127d12ac30a4f3c8" },
31 - "nvim-treesitter": { "branch": "master", "commit": "80cee52d445363c8bd08eacca17be31e3837f4d0" },
31 + "nvim-treesitter": { "branch": "master", "commit": "4613314b1f21b37694cf390ab3dc5262ba670798" },
32 32 "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },
33 - "nvim-ts-context-commentstring": { "branch": "main", "commit": "e9062e2dfb9854e6a927370f2d720de354c88524" },
34 - "nvim-web-devicons": { "branch": "master", "commit": "eb8f80f30fd5e9a6176dee5c46661ebd7437ac46" },
33 + "nvim-ts-context-commentstring": { "branch": "main", "commit": "9bff161dfece6ecf3459e6e46ca42e49f9ed939f" },
34 + "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" },
35 35 "oil.nvim": { "branch": "master", "commit": "0e5fca35cdc743cf3a448cea1a6251cf25cebafa" },
36 36 "persistence.nvim": { "branch": "main", "commit": "adcf6913693a0434665d162ee45a186230496f8a" },
37 37 "playground": { "branch": "master", "commit": "2b81a018a49f8e476341dfcb228b7b808baba68b" },
38 38 "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" },
39 39 "refactoring.nvim": { "branch": "master", "commit": "5359e74291164fcaeaaecdea9ba753ad54eb53d0" },
40 + "schemastore.nvim": { "branch": "main", "commit": "ce624332e6ba5a9a0c8f311a114ac179c5e72f62" },
40 41 "specs.nvim": { "branch": "main", "commit": "2743e412bbe21c9d73954c403d01e8de7377890d" },
41 42 "substitute.nvim": { "branch": "main", "commit": "42d09f1e6324d98aa2e5b765b64528e0aefe72b0" },
42 43 "telescope-symbols.nvim": { "branch": "master", "commit": "f2060117d965df4a626f068a4ebbd8ee051aa076" },
43 44 "telescope.nvim": { "branch": "0.1.x", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" },
44 45 "todo-comments.nvim": { "branch": "main", "commit": "8febc60a76feefd8203077ef78b6a262ea1a41f9" },
45 46 "toggleterm.nvim": { "branch": "main", "commit": "b90a1381e9b5b8596f49070ee86c71db267ac868" },
46 - "treesj": { "branch": "main", "commit": "00b382dc81eefaf42ad50a521e368f9057815bfb" },
47 + "treesj": { "branch": "main", "commit": "7ee1250292491dfdd8ac7eda4e1d373a8c2be7de" },
47 48 "twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" },
48 49 "virt-column.nvim": { "branch": "master", "commit": "1917bfb519729dea7b4f5d13aa9c810c9579b0ea" },
49 50 "zen-mode.nvim": { "branch": "main", "commit": "6e6c963d70a8e47854fa656987666bfb863f9c4e" }

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

Modified
4 4 local lua = require'bugabinga.lsp.clients.lua'
5 5 -- NOTE: The order of clients is implicitly priorization.
6 6 -- Put "more specific" clients first
7 7 return {
8 8 lua.nvim_lua_ls,
9 9 lua.lua_ls,
10 + require'bugabinga.lsp.clients.json',

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

Added
new file mode 100644
1 +local project = require'std.project'
3 +return {
4 + name = 'jsonls',
5 + filetypes = { 'json', 'jsonc' },
6 + command = { 'vscode-json-language-server', '--stdio' },
7 + root_dir = project.find_project_root,
8 + single_file_support = true,
9 + workspaces = false,
10 + init_options = {
11 + provideFormatter = true,
12 + },
13 + settings = {
14 + json = {
15 + schemas = require'schemastore'.json.schemas{
16 + extra = {
17 + description = 'Settings for lua-language-server',
18 + name = "LuaLS Settings",
19 + url = "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
20 + fileMatch = { ".luarc.json", ".luarc.jsonc" },
21 + }
22 + },
23 + validate = { enable = true },
24 + },
25 + },

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

Modified
1 1 local project = require'std.project'
3 --- TODO: share lua ls settings in shared table
4 3 local lua_ls =
6 5 name = 'LuaLS',

neovim/lua/bugabinga/lsp/init.lua

Modified
2 2 -- TODO: setup neodev + jsonls for neovim plugins ans config
3 3 -- TODO: setup nvimjdtls + lemminx for java/maven
4 4 -- TODO: setup marksman + ltex for markdown
5 5 -- TODO: setup mason for "less important" lsps
6 +-- TODO: some snippet plugins seems necessary for some LSPs
7 -local map = require'std.keymap'
8 -local auto = require'std.auto'
9 -local ui = require'bugabinga.ui'
10 -local table = require'std.table'
11 -local ignored = require'std.ignored'
8 +local map = require 'std.keymap'
9 +local auto = require 'std.auto'
10 +local ui = require 'bugabinga.ui'
11 +local table = require 'std.table'
12 +local ignored = require 'std.ignored'
13 -local lsp_client_configs = require'bugabinga.lsp.clients'
14 +local lsp_client_configs = require 'bugabinga.lsp.clients'
15 -local _ = {}
16 +local _ = {}
17 -local token_update = function(lsp_client)
18 +local token_update = function ( lsp_client )
18 19 local token = lsp_client.data.token
19 20 local buffer = lsp_client.buffer
20 21 local client_id = lsp_client.data.client_id
21 22 local mutable_variable_highlight = 'MutableVariable'
23 24 if token.type == 'variable' and not token.modifiers.readonly then
24 - vim.lsp.semantic_tokens.highlight_token(token, buffer, client_id, mutable_variable_highlight)
25 + vim.lsp.semantic_tokens.highlight_token( token, buffer, client_id, mutable_variable_highlight )
27 28 --TODO: find more use cases for semantic tokens
29 30 --* closures that capture something
32 -local lsp_start = function(file_type_event)
33 +local lsp_start = function ( file_type_event )
33 34 local match = file_type_event.match
35 36 local matches_to_ignore = ignored.filetypes
36 - if vim.iter(matches_to_ignore):find(match) then return end
37 + if vim.iter( matches_to_ignore ):find( match ) then return end
38 39 -- vim.print("LSP START", file_type_event)
40 41 local bufnr = file_type_event.buf
41 - local buffer_path = vim.api.nvim_buf_get_name(bufnr)
42 + local buffer_path = vim.api.nvim_buf_get_name( bufnr )
43 44 -- vim.print( "SEARCHING LSP CLIENT FOR:", match, buffer_path)
45 - local potential_client_configs = vim.iter(lsp_client_configs)
46 - :map(function(config)
47 - vim.validate{
46 + local potential_client_configs = vim.iter( lsp_client_configs )
47 + :map( function ( config )
48 + vim.validate {
48 49 config = { config, 'table' },
49 - ['config.name'] = { config.name, 'string'},
50 - ['config.filetypes']= { config.filetypes, {'string', 'table'}},
51 - ['config.command'] = { config.command, { 'string', 'table'}},
50 + ['config.name'] = { config.name, 'string' },
51 + ['config.filetypes'] = { config.filetypes, { 'string', 'table' } },
52 + ['config.command'] = { config.command, { 'string', 'table' } },
52 53 ['config.environment'] = { config.environment, 'table', true },
53 - ['config.root_dir'] = { config.root_dir, 'function', 'string'},
54 - ['config.single_file_support'] = { config.single_file_support, 'boolean'},
54 + ['config.root_dir'] = { config.root_dir, 'function', 'string' },
55 + ['config.single_file_support'] = { config.single_file_support, 'boolean' },
55 56 ['config.settings'] = { config.settings, 'table', true },
56 - ['config.workspaces'] = { config.workspaces, 'boolean'},
57 - ['config.before_init'] = { config.before_init, 'function', true},
57 + ['config.workspaces'] = { config.workspaces, 'boolean' },
58 + ['config.before_init'] = { config.before_init, 'function', true },
59 + ['config.init_options'] = { config.init_options, 'table', true },
60 + ['config.capabilities'] = { config.capabilities, 'table', true },
59 62 -- normalize scalar values to its vector alternative for easier processing later on
60 63 -- this mutates the lsp client configs! careful!
61 - config.command = type(config.command) == 'string' and { config.command } or config.command
62 - config.filetypes = type(config.filetypes) == 'string' and { config.filetypes } or config.filetypes
64 + config.command = type( config.command ) == 'string' and { config.command } or config.command
65 + config.filetypes = type( config.filetypes ) == 'string' and { config.filetypes } or config.filetypes
66 + config.capabilities = config.capabilities or {}
67 + config.init_options = config.init_options or {}
63 69 return config
64 - end)
65 - :filter(function(config)
66 - return vim.iter(config.filetypes):find(match)
67 - end)
68 - :totable()
70 + end )
71 + :filter( function ( config )
72 + return vim.iter( config.filetypes ):find( match )
73 + end )
74 + :totable()
70 76 -- vim.print("POTENTIAL CLIENTS", #potential_client_configs)
72 78 -- find clients, that returns some root_dir for this buffer
73 - local config = vim.iter(potential_client_configs):find(
74 - function(_) return _.root_dir(buffer_path) ~= nil end
79 + local config = vim.iter( potential_client_configs ):find(
80 + function ( _ ) return _.root_dir( buffer_path ) ~= nil end
77 83 -- if no client can open this buffer as part of a project (root_dir), then look
78 84 -- for a client with single file support
79 85 -- FIXME: root_dir needs to change if single file mode
80 - config = config or vim.iter(potential_client_configs):find(
81 - function(_) return _.single_file_support end
86 + config = config or vim.iter( potential_client_configs ):find(
87 + function ( _ ) return _.single_file_support end
84 90 if not config then
86 92 return
89 - assert(config, 'a matching LSP client config shoud have been found by now!')
95 + assert( config, 'a matching LSP client config shoud have been found by now!' )
97 + local root_dir = type(config.root_dir) == "string" and config.root_dir or config.root_dir( buffer_path )
98 + local capabilities = vim.lsp.protocol.make_client_capabilities()
99 + capabilities = table.extend("force", capabilities, config.capabilities)
91 101 local start_config = {
92 102 cmd = config.command,
93 - cmd_cwd = config.root_dir(buffer_path),
103 + cmd_cwd = root_dir,
94 104 -- cmd_env = config.environment,
95 105 detached = false, -- do i want this?
96 106 -- workspace_folders = { config.root_dir(buffer_path) }, -- TODO: i think workspaces can only ever be declared per project. i cannot think of a generic way to calculate those, like with root_dir. maybe a toml/ini file in root_dir sets these?
97 - -- capabilities = vim.lsp.protocol.make_client_capabilities(),
107 + capabilities = capabilities,
98 108 -- handlers = vim.lsp.handlers,
99 109 settings = config.settings,
100 110 -- commands = nil, -- what is this?
101 - -- init_options = nil,
111 + init_options = config.init_options,
102 112 name = config.name,
103 113 -- get_language_id = nil,
104 114 -- offset_encoding = nil,
105 - on_error = function(code, ...) vim.print('LSP ERROR', code, ...) end,
115 + on_error = function ( code, ... ) vim.print( 'LSP ERROR', code, ... ) end,
106 116 before_init = config.before_init,
107 117 -- on_init = nil, -- should i send workspace/didChangeConfiguration here?
108 118 -- on_exit = function(code, signal, client_id) vim.print("LSP CLIENT EXIT", code, signal, client_id) end,
109 119 -- on_attach = function(client, bufnr) vim.print("LSP CLIENT ATTACH", client.data.client_id, bufnr) end,
110 120 trace = 'off',
111 - flags = { allow_incremental_sync = true, debounce_text_changes = 50, exit_timeout = 200},
112 - root_dir = config.root_dir(buffer_path),
121 + flags = { allow_incremental_sync = true, debounce_text_changes = 50, exit_timeout = 200 },
122 + root_dir = root_dir,
115 - local client_id = vim.lsp.start(start_config, {
125 + local client_id = vim.lsp.start( start_config, {
116 126 bufnr = bufnr,
117 127 -- TODO: reuse if workspaces
118 128 -- local supported = vim.tbl_get(client, 'server_capabilities', 'workspace', 'workspaceFolders', 'supported')
119 129 -- reuse_client = function(existing_client, config)end,
120 - })
130 + } )
122 132 -- vim.print("ATTACHING LSP CLIENT", client_id)
126 136 local old_omnifunc
127 137 local old_tagfunc
129 -local s
131 ---TODO: setup keybinds on attach + omnifunc + tagfunc + folding
132 -local lsp_attach = function(args)
139 +local lsp_attach = function ( args )
133 140 local bufnr = args.buf
134 - local client = vim.lsp.get_client_by_id(args.data.client_id)
141 + local client = vim.lsp.get_client_by_id( args.data.client_id )
135 142 if not client then return end
137 144 -- vim.print(client.server_capabilities)
139 146 if client.server_capabilities.definitionProvider then
140 147 old_tagfunc = vim.bo[bufnr].tagfunc
141 - vim.bo[bufnr].tagfunc = "v:lua.vim.lsp.tagfunc"
148 + vim.bo[bufnr].tagfunc = 'v:lua.vim.lsp.tagfunc'
144 151 if client.server_capabilities.documentFormattingProvider then
145 152 old_formatexpr = vim.bo[bufnr].formatexpr
146 - vim.bo[bufnr].formatexpr = "v:lua.vim.lsp.formatexpr(#{timeout_ms:50})"
153 + vim.bo[bufnr].formatexpr = 'v:lua.vim.lsp.formatexpr(#{timeout_ms:50})'
149 156 if client.server_capabilities.completionProvider then
150 157 old_omnifunc = vim.bo[bufnr].omnifunc
151 - vim.bo[bufnr].omnifunc = "v:vim.lsp.omnifunc"
158 + vim.bo[bufnr].omnifunc = 'v:vim.lsp.omnifunc'
154 161 -- TODO: create register/unregister abstraction for lsp features
202 209 -- [4] ≔ 󰝗 lua.setConfig 󰉾,
203 210 -- [5] ≔ 󰝗 lua.getConfig 󰉾,
204 211 -- [6] ≔ 󰝗 lua.autoRequire 󰉾,
208 214 map.normal {
289 295 keys = '<c-7><c-7>',
290 296 command = '<cmd>Telescope lsp_signature_help<cr>',
295 -local lsp_detach = function(args)
300 +local lsp_detach = function ( args )
297 301 -- vim.print("DETACH LSP", ...)
299 303 local bufnr = args.buf
300 - local client = vim.lsp.get_client_by_id(args.data.client_id)
304 + local client = vim.lsp.get_client_by_id( args.data.client_id )
301 305 if not client then return end
303 307 if client.server_capabilities.definitionProvider then
312 316 vim.bo[bufnr].omnifunc = old_omnifunc
315 - if s then s() end
319 + if s then s() end
318 322 auto 'lsp' {
341 -local lsp_info = function(command)
345 +local lsp_info = function ( command )
342 346 local all_or_current = command.args and command.args == 'all' and {} or { bufnr = 0 }
343 - local active_clients = vim.lsp.get_clients(all_or_current)
347 + local active_clients = vim.lsp.get_clients( all_or_current )
345 - local infos = vim.iter(active_clients)
346 - :map(function(client)
349 + local infos = vim.iter( active_clients )
350 + :map( function ( client )
347 351 local name = client.name
348 - local config = vim.iter(lsp_client_configs):find(function(config) return config.name == name end)
349 - assert(config, ( 'How did we not find a config for %s ?!?!' ):format(name))
352 + local config = vim.iter( lsp_client_configs ):find( function ( config ) return config.name == name end )
353 + assert( config, ('How did we not find a config for %s ?!?!'):format( name ) )
351 - local full_cmd = table.deep_copy(client.config.cmd)
352 - full_cmd[1] = vim.fn.exepath(full_cmd[1])
355 + local full_cmd = table.deep_copy( client.config.cmd )
356 + full_cmd[1] = vim.fn.exepath( full_cmd[1] )
353 357 local basic = {
354 358 id = client.id,
355 359 name = name,
356 - cmd = table.concat(full_cmd, ' '),
357 - workspace_folders = vim.iter(client.workspace_folders):map(function(w) return vim.fs.normalize(w.name) end):totable(),
358 - filetypes = table.concat(config.filetypes, ', '),
360 + cmd = table.concat( full_cmd, ' ' ),
361 + workspace_folders = vim.iter( client.workspace_folders ):map( function ( w ) return vim.fs.normalize( w.name ) end )
362 + :totable(),
363 + filetypes = table.concat( config.filetypes, ', ' ),
359 364 single_file_support = config.single_file_support,
360 365 workspaces = config.workspaces,
362 367 return basic
363 - end)
368 + end )
364 369 :totable()
366 - ui.show_tree(infos)
371 + ui.show_tree( infos )
369 -local lsp_info_extended = function(command)
374 +local lsp_info_extended = function ( command )
370 375 local all_or_current = command.args and command.args == 'all' and {} or { bufnr = 0 }
371 - local active_clients = vim.lsp.get_clients(all_or_current)
372 - ui.show_tree(active_clients)
376 + local active_clients = vim.lsp.get_clients( all_or_current )
377 + ui.show_tree( active_clients )
375 -vim.api.nvim_create_user_command ('LspInfo',
380 +vim.api.nvim_create_user_command( 'LspInfo',
376 381 lsp_info,
378 383 nargs = '?',
379 - complete = function() return {"all"} end,
384 + complete = function () return { 'all' } end,
380 385 desc = 'Shows basic information about running LSP clients.',
381 - })
386 + } )
383 -vim.api.nvim_create_user_command ('LspInfoExtended',
388 +vim.api.nvim_create_user_command( 'LspInfoExtended',
384 389 lsp_info_extended,
386 391 nargs = '?',
387 - complete = function() return {"all"} end,
392 + complete = function () return { 'all' } end,
388 393 desc = 'Shows detailed information about running LSP clients.',
389 - })
390 -return setmetatable(_ ,{ })
394 + } )
395 +return setmetatable( _, {} )

neovim/lua/bugabinga/plugins/schemastore.lua

Added
new file mode 100644
1 +return {
2 + 'b0o/schemastore.nvim',
3 +}