dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Compare Notes Search neovim: normalize paths for win32
c72c7faa01ab61823f290eb0bbace29f0ee1f6ff
Oliver Krylow <o.krylow@isp-insoft.de > · 24 Jul 2023
unsigned
Browse files Compare with HEAD
Changed files (8) neovim/lua/bugabinga/diagnostic.lua Modified 1 1 local want
= require 'std.want' 2 2 local map
= require 'std.keymap' 3 + local auto
= require 'std.auto' 4 + local icon
= require 'std.icon' 4 - local icon
= {
' ' ,
' ' ,
' ' ,
' ' }
6 + local icon
= { icon.error, icon.warn, icon.info, icon.hint }
17 19 local diagnostic
= vim.diagnostic
19 - diagnostic.disable(
0 )
21 + auto
'disable_diagnostic_initially' {
22 + description =
'Disable Diagnostics initially, when attaching an LSP client to a buffer' ,
23 + events =
'LspAttach' ,
24 + command =
function () diagnostic.disable(
0 )
end ,
21 27 local diagnostic_format = function (context)
22 28 return string .
format (
'%s: %s' , display_name[context.severity], context.message)
42 48 source =
'if_many' ,
43 49 header =
'Diagnostic' ,
44 50 prefix = prefix_format,
51 57 local sign = function (options)
52 58 vim.fn.sign_define(options.name, {
53 - text = options.text,
54 - texthl = options.name,
59 + text = options.text,
60 + texthl = options.name,
61 67 sign {
name =
'DiagnosticSignError' ,
text = icon.error }
68 74 category
= 'diagnostic' ,
70 76 command = function ()
71 - if diagnostic.is_disabled(
0 )
then 72 - diagnostic.enable(
0 )
73 - vim.notify
'Enabling Diagnostics' 75 - diagnostic.disable(
0 )
76 - vim.notify
'Disabling Diagnostics' 77 + if diagnostic.is_disabled(
0 )
then 78 + diagnostic.enable(
0 )
79 + vim.notify
'Enabling Diagnostics' 81 + diagnostic.disable(
0 )
82 + vim.notify
'Disabling Diagnostics' 82 - name =
'Show diagnostics under cursor' ,
83 - category =
'diagnostic' ,
85 - command = diagnostic.open_float,
88 + name =
'Show diagnostics under cursor' ,
89 + category =
'diagnostic' ,
91 + command = diagnostic.open_float,
88 94 local show_diagnostics_in_buffer = function ()
89 - want{
'telescope.builtin' ,
'telescope.themes' }(
90 - function (builtin, themes)
91 - builtin.diagnostics(themes.get_dropdown{
bufnr =
0 })
95 + want{
'telescope.builtin' ,
'telescope.themes' }(
96 + function (builtin, themes)
97 + builtin.diagnostics(themes.get_dropdown{
bufnr =
0 })
96 - name =
'Show all diagnostics in buffer' ,
97 - category =
'diagnostic' ,
99 - command = show_diagnostics_in_buffer,
102 + name =
'Show all diagnostics in buffer' ,
103 + category =
'diagnostic' ,
105 + command = show_diagnostics_in_buffer,
102 108 local show_diagnostics_in_workspace = function ()
103 - want{
'telescope.builtin' ,
'telescope.themes' }(
104 - function (builtin, themes)
105 - builtin.diagnostics(themes.get_dropdown{})
109 + want{
'telescope.builtin' ,
'telescope.themes' }(
110 + function (builtin, themes)
111 + builtin.diagnostics(themes.get_dropdown{})
110 - name =
'Show all diagnostics in workspace' ,
111 - category =
'diagnostic' ,
112 - keys =
'<leader><F6>' ,
113 - command = show_diagnostics_in_workspace,
116 + name =
'Show all diagnostics in workspace' ,
117 + category =
'diagnostic' ,
118 + keys =
'<leader><F6>' ,
119 + command = show_diagnostics_in_workspace,
117 - name =
'Go to previous diagnostic' ,
118 - category =
'diagnostic' ,
120 - command = diagnostic.goto_prev,
123 + name =
'Go to previous diagnostic' ,
124 + category =
'diagnostic' ,
126 + command = diagnostic.goto_prev,
124 - name =
'Go to next diagnostic' ,
125 - category =
'diagnostic' ,
127 - command = diagnostic.goto_next,
130 + name =
'Go to next diagnostic' ,
131 + category =
'diagnostic' ,
133 + command = diagnostic.goto_next,
132 138 local dia = function ( severity, line )
133 - local ns
= vim.api.nvim_create_namespace(
'test' .. tostring (severity))
134 - local bufnr
= vim.api.nvim_get_current_buf()
140 - severity = severity,
141 - message =
'This is a test ' .. tostring (severity)
.. ' diagnostic' ,
139 + local ns
= vim.api.nvim_create_namespace(
'test' .. tostring (severity))
140 + local bufnr
= vim.api.nvim_get_current_buf()
146 + severity = severity,
147 + message =
'This is a test ' .. tostring (severity)
.. ' diagnostic' ,
144 - vim.diagnostic.set(ns, bufnr, {options})
145 - vim.diagnostic.show(ns, bufnr, {options})
150 + vim.diagnostic.set(ns, bufnr, {options})
151 + vim.diagnostic.show(ns, bufnr, {options})
148 154 local send_dia = function ()
149 - dia(vim.diagnostic.severity.ERROR,
1 )
150 - dia(vim.diagnostic.severity.WARN,
2 )
151 - dia(vim.diagnostic.severity.INFO,
3 )
152 - dia(vim.diagnostic.severity.HINT,
4 )
155 + dia(vim.diagnostic.severity.ERROR,
1 )
156 + dia(vim.diagnostic.severity.WARN,
2 )
157 + dia(vim.diagnostic.severity.INFO,
3 )
158 + dia(vim.diagnostic.severity.HINT,
4 )
155 - vim.g.send_dia
= send_dia
161 + vim.g.send_dia
= send_dia
neovim/lua/bugabinga/lsp/clients/lua.lua Modified 8 - cmd =
'lua-language-server' ,
8 + command =
'lua-language-server' ,
9 9 root_dir = project.find_lua_project_root,
10 10 single_file_support =
true ,
31 31 name =
'LuaLS(nvim)' ,
33 - cmd =
'lua-language-server' ,
33 + command =
'lua-language-server' ,
34 34 root_dir = project.find_lua_nvim_project_root,
35 35 single_file_support =
false ,
neovim/lua/bugabinga/lsp/init.lua Modified 37 - local buffer_path
= vim.api.nvim_buf_get_name(file_type_event.buf)
37 + local bufnr
= file_type_event.buf
38 + local buffer_path
= vim.api.nvim_buf_get_name(bufnr)
39 - vim.print(
"SEARCHING LSP CLIENT FOR:" , match, buffer_path)
41 42 local lsp_client_configs
= require 'bugabinga.lsp.clients' 43 - local potential_client_configs
= vim.iter(vim.deepcopy(lsp_client_configs))
44 + local potential_client_configs
= vim.iter(lsp_client_configs)
44 45 :map(
function (config)
46 47 config = { config,
'table' },
47 48 [
'config.name' ] = { config.name,
'string' },
48 49 [
'config.filetypes' ]= { config.filetypes, {
'string' ,
'table' }},
49 - [
'config.cmd' ] = { config.cmd, {
'string' ,
'table' }},
50 - [
'config.root_dir' ] = { config.root_dir,
'function' },
50 + [
'config.command' ] = { config.command, {
'string' ,
'table' }},
51 + [
'config.environment' ] = { config.environment,
'table' ,
true },
52 + [
'config.root_dir' ] = { config.root_dir,
'function' ,
'string' },
51 53 [
'config.single_file_support' ] = { config.single_file_support,
'boolean' },
54 + [
'config.settings' ] = { config.settings,
'table' ,
true },
52 55 [
'config.workspaces' ] = { config.workspaces,
'boolean' },
56 + [
'config.before_init' ] = { config.before_init,
'function' ,
true },
54 - config.cmd
= type (config.cmd)
== 'string' and { config.cmd }
or config.cmd
60 + config.command
= type (config.command)
== 'string' and { config.command }
or config.command
55 61 config.filetypes
= type (config.filetypes)
== 'string' and { config.filetypes }
or config.filetypes
56 - config.root_dir
= config.root_dir(buffer_path)
59 64 :filter(
function (config)
64 - vim.print(
"POTENTIAL CLIENTS" ,
# potential_client_configs)
67 72 local config
= vim.iter(potential_client_configs):find(
68 - function (_)
return _.root_dir
~= nil end 73 + function (_)
return _.root_dir(buffer_path)
~= nil end 75 80 function (_)
return _.single_file_support
end 78 - if config
then vim.print(
'FOUND LSP CLIENT' , config.name)
end 84 + vim.print(
'FOUND NO LSP CLIENT FOR' , buffer_path)
88 + assert (config,
'a matching LSP client config shoud have been found by now!' )
90 + local start_config
= {
91 + cmd = config.command,
92 + cmd_cwd = config.root_dir(buffer_path),
98 + settings = config.settings,
101 + name = config.name,
104 + on_error =
function (code,
... ) vim.print(
'LSP ERROR' , code,
... )
end ,
105 + before_init = config.before_init,
107 + on_exit =
function (code, signal, client_id) vim.print(
"LSP CLIENT EXIT" , code, signal, client_id)
end ,
108 + on_attach =
function (client, bufnr) vim.print(
"LSP CLIENT ATTACH" , client, bufnr)
end ,
110 + flags = {
allow_incremental_sync =
true ,
debounce_text_changes =
50 ,
exit_timeout =
200 },
111 + root_dir = config.root_dir(buffer_path),
81 - local client_id
= vim.lsp.start(config)
115 + local client_id
= vim.lsp.start(start_config, {
82 122 vim.print(
"ATTACHING LSP CLIENT" , client_id)
89 125 local lsp_attach = function (
... ) vim.print(
"ATTACH LSP" ,
... )
end 90 126 local lsp_detach = function (
... ) vim.print(
"DETACH LSP" ,
... )
end neovim/lua/bugabinga/plugins/heirline.lua Modified 113 113 local file_name
= {
114 114 init =
function (self)
115 - self.lfilename
= vim.fn.fnamemodify(self.filename,
":." )
116 - if self.lfilename
== "" then self.lfilename
= "~scratch~" end 115 + self.lfilename
= vim.fs.normalize(vim.fn.fnamemodify(self.filename,
":." ))
116 + if self.lfilename
== "" then self.lfilename
= "~new~" end 127 127 provider =
function (self)
128 - return vim.fn.pathshorten(self.lfilename)
128 + return vim.fs.normalize(vim.fn.pathshorten(self.lfilename))
150 150 local file_name_block
= {
151 151 init =
function (self)
152 - self.filename
= vim.api.nvim_buf_get_name(
0 )
152 + self.filename
= vim.fs.normalize(vim.api.nvim_buf_get_name(
0 ))
216 216 provider = function ()
218 - for i, server
in pairs (vim.lsp.get_active_clients{
bufnr =
0 })
do 219 - table .
insert (names, server.name)
218 + for i, client
in pairs (vim.lsp.get_active_clients{
bufnr =
0 })
do 219 + table .
insert (names, client.name)
221 - return icon.lsp
.. " [" .. table .
concat (names,
" " )
.. "]" 221 + return icon.lsp
.. " " .. table .
concat (names,
" " )
235 235 condition
= conditions.has_diagnostics,
238 - error_icon = vim.fn.sign_getdefined(
"DiagnosticSignError" )[
1 ].text,
239 - warn_icon = vim.fn.sign_getdefined(
"DiagnosticSignWarn" )[
1 ].text,
240 - info_icon = vim.fn.sign_getdefined(
"DiagnosticSignInfo" )[
1 ].text,
241 - hint_icon = vim.fn.sign_getdefined(
"DiagnosticSignHint" )[
1 ].text,
238 + error_icon = icon.error,
239 + warn_icon = icon.warn,
240 + info_icon = icon.info,
241 + hint_icon = icon.hint,
244 244 init = function (self)
356 356 local work_dir
= {
357 357 init =
function (self)
358 - self.icon
= (vim.fn.haslocaldir(
0 )
== 1 and "local" or "" )
.. " " .. icon.folder
.. " " 359 - local cwd
= vim.fn.getcwd(
0 )
360 - self.cwd
= vim.fn.fnamemodify(cwd,
":~" )
358 + self.icon
= (vim.fn.haslocaldir(
0 )
== 1 and icon[
'local' ]
or "" )
.. " " .. icon.global
.. " " 359 + self.cwd
= vim.fs.normalize(vim.uv.cwd()):gsub(vim.fs.normalize(vim.uv.os_homedir()),
"~" )
367 366 provider =
function (self)
368 - local trail
= self.cwd:sub(
- 1 )
== "/" and "" or "/" 369 - return self.icon
.. self.cwd
.. trail
367 + return self.icon
.. self.cwd
374 372 provider =
function (self)
375 373 local cwd
= vim.fn.pathshorten(self.cwd)
376 - local trail
= self.cwd:sub(
- 1 )
== "/" and "" or "/" 377 - return self.icon
.. cwd
.. trail
374 + return self.icon
.. cwd
neovim/lua/bugabinga/plugins/neodev.lua Modified neovim/lua/std/icon.lua Modified neovim/lua/std/project.lua Modified 4 4 local join
= require 'std.table' .join
5 5 local dirname
= vim.fs.dirname
6 6 local normalize
= vim.fs.normalize
7 7 local exists
= vim.loop.fs_stat
8 8 local validate
= vim.validate
11 15 local MAX_TRAVERSAL_COUNT
= 100