dotfiles
bugabingas dorkfiles
owned by bugabinga
neovim: playing around with project root logic
c498152a7844a61971f6d53918cbf43c1f54e05d
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (9)
neovim/.luarc.jsonc
Deleteddeleted file mode 100644 2 - "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
7 - "neededFileStatus": {
8 - "codestyle-check": "Any"
12 - "checkThirdParty": false
15 - "version": "LuaJIT",
neovim/lazy-lock.json
Modified16 16 "hyper.nvim": {
"branch":
"main",
"commit":
"b84fb39e703b1dd487d20c4faf028ee51374c88b" },
17 17 "indent-blankline.nvim": {
"branch":
"master",
"commit":
"821a7acd88587d966f7e464b0b3031dfe7f5680c" },
18 18 "lazy.nvim": {
"branch":
"main",
"commit":
"83493db50a434a4c5c648faf41e2ead80f96e478" },
19 + "lsp_signature.nvim": {
"branch":
"master",
"commit":
"c6aeb2f1d2538bbdfdaab1664d9d4c3c75aa9db8" },
19 20 "mason-tool-installer.nvim": {
"branch":
"main",
"commit":
"1212fb6082b7177dde17ea65e429e027835aeb40" },
20 21 "mason.nvim": {
"branch":
"main",
"commit":
"c43eeb5614a09dc17c03a7fb49de2e05de203924" },
21 22 "mini.align": {
"branch":
"main",
"commit":
"f845218c5fea89e49074e48270dc5e1b9511a0f9" },
neovim/lua/bugabinga/lsp/clients/lua.lua
Modified13 13 addonManager = {
enable =
false, },
14 - completion = {
callSnippet =
'Disable',
postfix =
'.', },
14 + completion = {
callSnippet =
'Replace', },
15 15 diagnostics = {
globals = {
'vim', },
workspaceRate =
50, },
16 16 hint = {
enable =
true,
setType =
true, },
17 17 telemetry = {
enable =
false, },
neovim/lua/bugabinga/lsp/init.lua
Modified193 193 local old_tagfunc
195 195 local keybinds
= {}
196 -local add = function ( client_id, keybind )
196 +local add = function ( client_id, keybind_remover )
198 + client_id = { client_id,
'number', },
199 + keybind_remover = { keybind_remover,
'function', },
197 201 if not table.contains( keybinds, client_id )
then 198 202 keybinds[client_id]
= {}
200 - table.
insert( keybinds[client_id], keybind )
204 + table.
insert( keybinds[client_id], keybind_remover )
203 207 local lsp_attach = function ( args )
204 208 local bufnr
= args.buf
205 - local client
= vim.lsp.get_client_by_id( args.data.client_id )
209 + local client_id
= args.data.client_id
210 + local client
= vim.lsp.get_client_by_id( client_id )
206 211 if not client
then return end 208 213 debug.print( client.server_capabilities )
245 + local lsp_signature_ok, lsp_signature
= pcall(
require,
'lsp_signature' )
246 + if lsp_signature_ok
then 247 + lsp_signature.on_attach( {}, bufnr )
240 250 if client.server_capabilities.documentHighlightProvider
then 242 252 local delay
= 300 262 272 if client.server_capabilities.inlayHintProvider
then 273 + add( client_id, map.normal {
264 274 description =
'Toggle inlay hints',
265 275 category =
'lsp',
267 277 keys =
'<leader>ti',
268 278 command =
function ()
269 - vim.lsp.inlay_hint( bufnr,
nil )
279 + vim.lsp.inlay_hint.enable( bufnr,
nil )
284 + add( client_id, map.normal {
275 285 description =
'Show hover documentation above cursor.',
276 286 category =
'lsp',
279 289 command
= vim.lsp.buf.hover,
292 + add( client_id, map.normal {
283 293 description =
'Show signature help under cursor.',
284 294 category =
'lsp',
287 297 command
= vim.lsp.buf.signature_help,
300 + add( client_id, map.normal {
291 301 description =
'Show available code actions on current line.',
292 302 category =
'lsp',
295 305 command
= vim.lsp.buf.code_action,
308 + add( client_id, map.normal {
299 309 description =
'Goto to definition of symbol under cursor.',
300 310 category =
'lsp',
303 313 command
= vim.lsp.buf.definition,
316 + add( client_id, map.normal {
307 317 description =
'Show implementations of symbol under cursor.',
308 318 category =
'lsp',
311 321 command
= vim.lsp.buf.implementation,
324 + add( client_id, map.normal {
315 325 description =
'Show incoming calls of symbol under cursor.',
316 326 category =
'lsp',
319 329 command
= vim.lsp.buf.incoming_calls,
332 + add( client_id, map.normal {
323 333 description =
'Show outgoing calls of symbol under cursor.',
324 334 category =
'lsp',
327 337 command
= vim.lsp.buf.outgoing_calls,
340 + add( client_id, map.normal {
331 341 description =
'Show references of symbol under cursor.',
332 342 category =
'lsp',
335 345 command
= vim.lsp.buf.references,
348 + add( client_id, map.normal {
339 349 description =
'Rename symbol under cursor.',
340 350 category =
'lsp',
neovim/lua/bugabinga/nugu/init.lua
Modified204 204 _.Define
= _.PreProc
205 205 _.Macro
= _.PreProc
206 206 _.PreCondit
= _.PreProc
207 +_.Parameter {
fg = content_focus, }
208 209 _.Type
= _.Statement
209 210 _.StorageClass
= _.Statement
276 277 _[
'@function']
= _.Function
277 278 _[
'@function.builtin']
= _.Special
278 279 _[
'@function.macro']
= _.Macro
279 -_[
'@parameter']
= _.Identifier
280 +_[
'@parameter']
= _.Parameter
280 281 _[
'@method']
= _.Function
281 282 _[
'@field']
= _.Identifier
282 283 _[
'@property']
= _.Identifier
293 294 _[
'@type.definition']
= _.Typedef
294 295 _[
'@storageclass']
= _.StorageClass
295 296 _[
'@structure']
= _.Structure
296 -_[
'@namespace']
= _.Identifier
297 +_[
'@namespace']
= _.PreProc
297 298 _[
'@include']
= _.Include
298 299 _[
'@preproc']
= _.PreProc
299 300 _[
'@debug']
= _.Debug
518 519 _.IblWhitespace
= _.Whitespace
519 520 _.IblScope {
fg = ui_focus,
bg = _.Normal.bg, }
521 -_.Hlargs {
fg = content_important_local, }
523 523 _.MiniStarterCurrent {
fg = ui_normal,
bg = ui_accent, }
524 524 _.MiniStarterFooter
= _.Keyword
neovim/lua/bugabinga/plugins/hlargs.lua
Deleteddeleted file mode 100644 2 - 'm-demare/hlargs.nvim',
3 - event = {
'BufRead',
'BufLeave',
'BufEnter',
'SessionLoadPost', },
6 - paint_arg_declarations =
true,
7 - paint_arg_usages =
true,
8 - paint_catch_blocks = {
12 - extras = {
named_parameter =
true, },
13 - excluded_argnames = {
15 - usages = {
lua = {}, },
19 - 'nvim-treesitter/nvim-treesitter',
neovim/lua/bugabinga/plugins/lsp_signature.lua
Addednew file mode 100644 2 + 'ray-x/lsp_signature.nvim',
5 + debug =
require 'std.debug'.get(),
neovim/lua/bugabinga/plugins/neodev.lua
Modified 5 6 override =
function ( root_dir, library )
neovim/lua/std/project.lua
Modified 11 11 local markers_to_string = function ( markers )
12 12 return vim.inspect( markers )
14 -local create_hash = function ( path, markers )
14 +local create_hash = function ( path, markers, stop )
15 15 local path_hash
= hasher( path )
16 + local stop_hash
= hasher( stop )
16 17 local markers_hash
= hasher( markers_to_string( markers ) )
17 - local hash
= path_hash
.. '|' .. markers_hash
18 + local hash
= path_hash
.. '|' .. markers_hash
.. '|' .. stop_hash
20 -local cache_get = function ( path, markers )
21 - local hash
= create_hash( path, markers )
21 +local cache_get = function ( path, markers, stop )
22 + local hash
= create_hash( path, markers, stop )
22 23 local hit
= cache[hash]
25 -local cache_set = function ( project_root, path, markers )
26 - local hash
= create_hash( path, markers )
26 +local cache_set = function ( project_root, path, markers, stop )
27 + local hash
= create_hash( path, markers, stop )
27 28 cache[hash]
= project_root
86 87 if #path
== 0 then return nil end 88 - local cache_hit
= cache_get( path, markers )
89 + local cache_hit
= cache_get( path, markers, stop )
90 91 debug.print(
'CACHE HIT', cache_hit )
135 136 local project_root
= nil 136 137 local max_likelyhood
= 0 143 144 for _, score
in ipairs( directory_scores )
do 144 - local likelihood
= score.marker_count
+ score.distance_to_buffer_file
145 - if likelihood
> max_likelyhood
then 146 - max_likelyhood
= likelihood
145 + local likelyhood
= score.marker_count
* (
1 / score.distance_to_buffer_file)
146 + if debug.get()
then score.likelyhood
= likelyhood
end 147 + if likelyhood
> max_likelyhood
then 148 + max_likelyhood
= likelyhood
147 149 project_root
= score.path
150 152 if project_root
then 151 - cache_set( project_root, path, markers )
153 + cache_set( project_root, path, markers, stop )
155 + debug.print(
'found project root', project_root, directory_scores )
153 156 return project_root
162 165 local function find_project_root( path, markers )
164 167 local default_markers
= {
165 - {
name =
'.git',
weight = LIKELY, },
166 - {
name =
'.gitignore',
weight = LIKELY, },
167 - {
name =
'.svn',
weight = LIKELY, },
168 - {
name =
'justfile',
weight = LIKELY, },
169 - {
name =
'Jenkinsfile',
weight = MAYBE, },
170 - {
name =
'.editorconfig',
weight = MAYBE, },
171 - {
name =
'LICENSE',
weight = MAYBE, },
172 - {
name =
'LICENSE.md',
weight = MAYBE, },
173 - {
name =
'LICENSE.txt',
weight = MAYBE, },
174 - {
name =
'COPYING',
weight = MAYBE, },
175 - {
name =
'README',
weight = MAYBE, },
176 - {
name =
'README.md',
weight = MAYBE, },
177 - {
name =
'Makefile',
weight = LIKELY, },
178 - {
name =
'flake.nix',
weight = MAYBE, },
179 - {
name =
'flake.nix',
weight = MAYBE, },
180 - {
name =
'.project_model',
weight = DEFINITLY, },
168 + {
name =
'.git',
weight = LIKELY, },
169 + {
name =
'.gitignore',
weight = LIKELY, },
170 + {
name =
'.svn',
weight = LIKELY, },
171 + {
name =
'justfile',
weight = LIKELY, },
172 + {
name =
'Jenkinsfile',
weight = MAYBE, },
173 + {
name =
'.editorconfig',
weight = MAYBE, },
174 + {
name =
'LICENSE',
weight = MAYBE, },
175 + {
name =
'LICENSE.md',
weight = MAYBE, },
176 + {
name =
'LICENSE.txt',
weight = MAYBE, },
177 + {
name =
'COPYING',
weight = MAYBE, },
178 + {
name =
'README',
weight = MAYBE, },
179 + {
name =
'README.md',
weight = MAYBE, },
180 + {
name =
'Makefile',
weight = LIKELY, },
181 + {
name =
'flake.nix',
weight = MAYBE, },
182 + {
name =
'flake.nix',
weight = MAYBE, },
183 + {
name =
'.project_model.lua',
weight = DEFINITLY, },
183 186 markers
= markers
or {}
205 208 {
name =
'gradlew',
weight = DEFINITLY, },
206 209 {
name =
'gradlew.bat',
weight = DEFINITLY, },
208 - return find_root( path, java_markers )
211 + return find_project_root( path, java_markers )
211 -local lua_markers
= {
212 - {
name =
'.luarc.json',
weight = MAYBE, },
213 - {
name =
'.luarc.jsonc',
weight = MAYBE, },
214 - {
name =
'.luacheckrc',
weight = MAYBE, },
215 - {
name =
'.stylua.toml',
weight = MAYBE, },
216 - {
name =
'stylua.toml',
weight = MAYBE, },
217 - {
name =
'selene.toml',
weight = MAYBE, },
218 - {
name =
'selene.yml',
weight = MAYBE, },
219 - {
name =
'neovim.yml',
weight = MAYBE, },
220 - {
name =
'lua',
weight = MAYBE, },
223 214 local find_lua_project_root = function ( path )
224 - return find_root( path, lua_markers )
215 + local lua_markers
= {
216 + {
name =
'.luarc.json',
weight = MAYBE, },
217 + {
name =
'.luarc.jsonc',
weight = MAYBE, },
218 + {
name =
'.luacheckrc',
weight = MAYBE, },
219 + {
name =
'.stylua.toml',
weight = MAYBE, },
220 + {
name =
'stylua.toml',
weight = MAYBE, },
221 + {
name =
'selene.toml',
weight = MAYBE, },
222 + {
name =
'selene.yml',
weight = MAYBE, },
223 + {
name =
'neovim.yml',
weight = MAYBE, },
224 + {
name =
'lua',
weight = MAYBE, },
227 + return find_project_root( path, lua_markers )
227 -local zig_markers
= {
228 - {
name =
'build.zig',
weight = DEFINITLY, },
229 - {
name =
'zls.build.json',
weight = DEFINITLY, },
230 - {
name =
'zig-cache',
weight = MAYBE, },
231 - {
name =
'zig-out',
weight = MAYBE, },
234 230 local find_zig_project_root = function ( path )
235 - return find_root( path, zig_markers )
231 + local zig_markers
= {
232 + {
name =
'build.zig',
weight = DEFINITLY, },
233 + {
name =
'zls.build.json',
weight = DEFINITLY, },
234 + {
name =
'zig-cache',
weight = MAYBE, },
235 + {
name =
'zig-out',
weight = MAYBE, },
239 + return find_project_root( path, zig_markers )
238 242 local find_rust_project_root = function ( path )
239 243 local markers
= {
240 244 {
name =
'Cargo.toml',
weight = DEFINITLY, },
242 - local cargo_crate_dir
= find_root( path, markers )
246 + local cargo_crate_dir
= find_project_root( path, markers )
243 247 if cargo_crate_dir
== nil then return nil end