summaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/lua/plugins
diff options
context:
space:
mode:
authorMichaël Ball <michael.ball@krotosaudio.com>2024-07-19 14:16:35 +0100
committerMichaël Ball <michael.ball@krotosaudio.com>2024-07-19 14:16:35 +0100
commit1616a0741806e74aaf85f6b3539de374c3ca3249 (patch)
tree91393b3a3222877e58da27f4b2d8d8f33ebac3ca /neovim/.config/nvim/lua/plugins
parent457ce9e6017c081e02a566895fa1fe488cd87b9c (diff)
Refactor neovim config
Diffstat (limited to 'neovim/.config/nvim/lua/plugins')
-rw-r--r--neovim/.config/nvim/lua/plugins/galaxyline.lua136
-rw-r--r--neovim/.config/nvim/lua/plugins/lspsaga.lua3
-rw-r--r--neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua173
3 files changed, 190 insertions, 122 deletions
diff --git a/neovim/.config/nvim/lua/plugins/galaxyline.lua b/neovim/.config/nvim/lua/plugins/galaxyline.lua
index 9f58157..f2edff6 100644
--- a/neovim/.config/nvim/lua/plugins/galaxyline.lua
+++ b/neovim/.config/nvim/lua/plugins/galaxyline.lua
@@ -10,11 +10,33 @@ return {
'arzg/vim-colors-xcode',
lazy = false,
priority = 1000,
- config = function()
- vim.cmd[[colorscheme xcode]]
- end
+ config = function ()
+ local colorscheme_rules_augroup = vim.api.nvim_create_augroup('Colors', {})
+ vim.api.nvim_create_autocmd( { 'ColorScheme' }, {
+ pattern = { '*' },
+ group = colorscheme_rules_augroup,
+ callback = function()
+ vim.api.nvim_set_hl(0, 'WinSeparator', { link='VertSplit', force=1, default=1 })
+ end,
+ })
+ end,
+ dependencies = {
+ {
+ 'f-person/auto-dark-mode.nvim',
+ opts = {
+ update_interval = 1000,
+ set_dark_mode = function ()
+ vim.api.nvim_set_option('background', 'dark')
+ end,
+ set_light_mode = function ()
+ vim.api.nvim_set_option('background', 'light')
+ end
+ }
+ }
+ },
},
},
+ event = 'VimEnter',
config = function()
local gl = require('galaxyline')
local colors = {
@@ -31,50 +53,66 @@ return {
local condition = require('galaxyline.condition')
local gls = gl.section
local lsp = require('galaxyline.provider_lsp')
- gl.short_line_list = {'nerdtree', 'NeogitStatus', 'vim-plug', 'lspsagaoutline'}
+ gl.short_line_list = { 'nerdtree', 'NeogitStatus', 'vim-plug', 'lspsagaoutline', 'neo-tree' }
gls.left[1] = {
RainbowBlue = {
- provider = function() return '▊ ' end,
- highlight = {colors.blue, 'StatusLine'}
+ provider = function()
+ return '▊ '
+ end,
+ highlight = { colors.blue, 'StatusLine' }
},
}
gls.left[2] = {
ViMode = {
provider = function()
-- auto change color according the vim mode
- local mode_color = {n = colors.red, i = colors.green,v=colors.blue,
- ['^V'] = colors.blue,V=colors.blue,
- c = colors.magenta,no = colors.red,s = colors.orange,
- S=colors.orange,['^S'] = colors.orange,
- ic = colors.yellow,R = colors.violet,Rv = colors.violet,
- cv = colors.red,ce=colors.red, r = colors.cyan,
- rm = colors.cyan, ['r?'] = colors.cyan,
- ['!'] = colors.red,t = colors.red}
- vim.api.nvim_command('hi GalaxyViMode guifg='..mode_color[vim.fn.mode()])
+ local mode_color = {
+ n = colors.red,
+ i = colors.green,
+ v = colors.blue,
+ ['^V'] = colors.blue,
+ V = colors.blue,
+ c = colors.magenta,
+ no = colors.red,
+ s = colors.orange,
+ S = colors.orange,
+ ['^S'] = colors.orange,
+ ic = colors.yellow,
+ R = colors.violet,
+ Rv = colors.violet,
+ cv = colors.red,
+ ce = colors.red,
+ r = colors.cyan,
+ rm = colors.cyan,
+ ['r?'] = colors.cyan,
+ ['!'] = colors.red,
+ t = colors.red
+ }
+ vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()])
return ' '
end,
- highlight = {colors.red, 'StatusLine', 'bold'},
- },
+ highlight = { colors.red, 'StatusLine', 'bold' },
+ },
}
gls.left[3] = {
FileSize = {
provider = 'FileSize',
condition = condition.buffer_not_empty,
- highlight = {'StatusLine', 'StatusLine'},
+ highlight = { 'StatusLine', 'StatusLine' },
}
}
- gls.left[4] ={
+ gls.left[4] = {
FileIcon = {
provider = 'FileIcon',
condition = function()
- if vim.g.GtkGuiLoaded ~= nil and condition.buffer_not_empty() then
- return true
- end
- return false
+ if vim.g.GtkGuiLoaded ~= nil and condition.buffer_not_empty() then
+ return true
+ end
+ return false
end,
- highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color, 'StatusLine'},
+ highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, 'StatusLine' },
},
}
@@ -82,7 +120,7 @@ return {
FileName = {
provider = 'FileName',
condition = condition.buffer_not_empty,
- highlight = {colors.magenta, 'StatusLine', 'bold'}
+ highlight = { colors.magenta, 'StatusLine', 'bold' }
}
}
@@ -90,8 +128,8 @@ return {
LineInfo = {
provider = 'LineColumn',
separator = ' ',
- separator_highlight = {'NONE', 'StatusLine'},
- highlight = {'NONE', 'StatusLine'},
+ separator_highlight = { 'NONE', 'StatusLine' },
+ highlight = { 'NONE', 'StatusLine' },
},
}
@@ -99,8 +137,8 @@ return {
PerCent = {
provider = 'LinePercent',
separator = ' ',
- separator_highlight = {'NONE', 'StatusLine'},
- highlight = {'NONE', 'StatusLine', 'bold'},
+ separator_highlight = { 'NONE', 'StatusLine' },
+ highlight = { 'NONE', 'StatusLine', 'bold' },
}
}
@@ -108,14 +146,14 @@ return {
DiagnosticError = {
provider = 'DiagnosticError',
icon = '  ',
- highlight = {colors.red, 'StatusLine'}
+ highlight = { colors.red, 'StatusLine' }
}
}
gls.left[9] = {
DiagnosticWarn = {
provider = 'DiagnosticWarn',
icon = '  ',
- highlight = {colors.yellow, 'StatusLine'},
+ highlight = { colors.yellow, 'StatusLine' },
}
}
@@ -123,7 +161,7 @@ return {
DiagnosticHint = {
provider = 'DiagnosticHint',
icon = '  ',
- highlight = {colors.cyan, 'StatusLine'},
+ highlight = { colors.cyan, 'StatusLine' },
}
}
@@ -131,15 +169,15 @@ return {
DiagnosticInfo = {
provider = 'DiagnosticInfo',
icon = '  ',
- highlight = {colors.blue, 'StatusLine'},
+ highlight = { colors.blue, 'StatusLine' },
}
}
gls.mid[1] = {
ShowLspClient = {
provider = 'GetLspClient',
- condition = function ()
- local tbl = {['dashboard'] = true,['']=true}
+ condition = function()
+ local tbl = { ['dashboard'] = true, [''] = true }
if tbl[vim.bo.filetype] then
return false
elseif lsp.get_lsp_client() == 'No Active Lsp' then
@@ -148,7 +186,7 @@ return {
return true
end,
icon = '⚙ LSP:',
- highlight = {colors.cyan, 'StatusLine','bold'}
+ highlight = { colors.cyan, 'StatusLine', 'bold' }
}
}
@@ -157,8 +195,8 @@ return {
provider = function() return '  ' end,
condition = condition.check_git_workspace,
separator = ' ',
- separator_highlight = {'NONE', 'StatusLine'},
- highlight = {colors.violet, 'StatusLine', 'bold'},
+ separator_highlight = { 'NONE', 'StatusLine' },
+ highlight = { colors.violet, 'StatusLine', 'bold' },
}
}
@@ -166,7 +204,7 @@ return {
GitBranch = {
provider = 'GitBranch',
condition = condition.check_git_workspace,
- highlight = {colors.violet, 'StatusLine', 'bold'},
+ highlight = { colors.violet, 'StatusLine', 'bold' },
}
}
@@ -175,7 +213,7 @@ return {
provider = 'DiffAdd',
condition = condition.hide_in_width,
icon = ' +',
- highlight = {colors.green, 'StatusLine'},
+ highlight = { colors.green, 'StatusLine' },
}
}
gls.right[4] = {
@@ -183,7 +221,7 @@ return {
provider = 'DiffModified',
condition = condition.hide_in_width,
icon = ' ±',
- highlight = {colors.orange, 'StatusLine'},
+ highlight = { colors.orange, 'StatusLine' },
}
}
gls.right[5] = {
@@ -191,14 +229,14 @@ return {
provider = 'DiffRemove',
condition = condition.hide_in_width,
icon = ' -',
- highlight = {colors.red, 'StatusLine'},
+ highlight = { colors.red, 'StatusLine' },
}
}
gls.right[6] = {
RainbowBlue = {
provider = function() return ' ▊' end,
- highlight = {colors.blue, 'StatusLine'}
+ highlight = { colors.blue, 'StatusLine' }
},
}
@@ -206,23 +244,23 @@ return {
BufferType = {
provider = 'FileTypeName',
separator = ' ',
- separator_highlight = {'NONE', 'StatusLine'},
- highlight = {colors.blue, 'StatusLine', 'bold'}
+ separator_highlight = { 'NONE', 'StatusLine' },
+ highlight = { colors.blue, 'StatusLine', 'bold' }
}
}
gls.short_line_left[2] = {
SFileName = {
- provider = 'SFileName',
+ provider = 'SFileName',
condition = condition.buffer_not_empty,
- highlight = {'StatusLine', 'StatusLine', 'bold'}
+ highlight = { 'StatusLine', 'StatusLine', 'bold' }
}
}
gls.short_line_right[1] = {
BufferIcon = {
- provider= 'BufferIcon',
- highlight = {'StatusLine', 'StatusLine'},
+ provider = 'BufferIcon',
+ highlight = { 'StatusLine', 'StatusLine' },
}
}
end,
diff --git a/neovim/.config/nvim/lua/plugins/lspsaga.lua b/neovim/.config/nvim/lua/plugins/lspsaga.lua
index 1fe1194..f9414e8 100644
--- a/neovim/.config/nvim/lua/plugins/lspsaga.lua
+++ b/neovim/.config/nvim/lua/plugins/lspsaga.lua
@@ -1,8 +1,7 @@
return {
{
'nvimdev/lspsaga.nvim',
- lazy = false,
- priority = 500,
+ event = 'LspAttach',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
diff --git a/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua b/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua
index f03db19..3d02f49 100644
--- a/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua
+++ b/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua
@@ -1,80 +1,111 @@
return {
- {
- 'neovim/nvim-lspconfig',
- lazy = false,
- priority = 800,
- config = function()
- local nvim_lsp = require('lspconfig')
- local capabilities = require('cmp_nvim_lsp').default_capabilities()
- -- Use a loop to conveniently call 'setup' on multiple servers and
- -- map buffer local keybindings when the language server attaches
- local servers = { "bashls", "clangd", "cssls", "gopls", "html", "jsonls", "pylsp", "rust_analyzer", "yamlls" }
- for _, lsp in ipairs(servers) do
- nvim_lsp[lsp].setup {
- capabilities = capabilities,
- flags = {
- debounce_text_changes = 150,
- }
- }
- end
+ {
+ 'neovim/nvim-lspconfig',
+ lazy = false,
+ priority = 800,
+ config = function()
+ local nvim_lsp = require('lspconfig')
+ local capabilities = require('cmp_nvim_lsp').default_capabilities()
+ -- Use a loop to conveniently call 'setup' on multiple servers and
+ -- map buffer local keybindings when the language server attaches
+ local servers = { "bashls", "clangd", "cssls", "gopls", "html", "jsonls", "rust_analyzer", "yamlls" }
+ for _, lsp in ipairs(servers) do
+ nvim_lsp[lsp].setup {
+ capabilities = capabilities,
+ flags = {
+ debounce_text_changes = 150,
+ }
+ }
+ end
- require'lspconfig'.lua_ls.setup {
- on_init = function(client)
- local path = client.workspace_folders[1].name
- if vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc') then
- return
- end
+ require 'lspconfig'.lua_ls.setup {
+ on_init = function(client)
+ local path = client.workspace_folders[1].name
+ if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then
+ return
+ end
- client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
- runtime = {
- -- Tell the language server which version of Lua you're using
- -- (most likely LuaJIT in the case of Neovim)
- version = 'LuaJIT'
- },
- -- Make the server aware of Neovim runtime files
- workspace = {
- checkThirdParty = false,
- library = {
- vim.env.VIMRUNTIME
- -- Depending on the usage, you might want to add additional paths here.
- -- "${3rd}/luv/library"
- -- "${3rd}/busted/library",
- }
- -- or pull in all of 'runtimepath'. NOTE: this is a lot slower
- -- library = vim.api.nvim_get_runtime_file("", true)
+ client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
+ runtime = {
+ -- Tell the language server which version of Lua you're using
+ -- (most likely LuaJIT in the case of Neovim)
+ version = 'LuaJIT'
+ },
+ -- Make the server aware of Neovim runtime files
+ workspace = {
+ checkThirdParty = false,
+ library = {
+ vim.env.VIMRUNTIME
+ -- Depending on the usage, you might want to add additional paths here.
+ -- "${3rd}/luv/library"
+ -- "${3rd}/busted/library",
+ }
+ -- or pull in all of 'runtimepath'. NOTE: this is a lot slower
+ -- library = vim.api.nvim_get_runtime_file("", true)
+ }
+ })
+ end,
+ settings = {
+ Lua = {
+ format = {
+ enable = true,
+ defaultConfig = {
+ indent_style = "space",
+ indent_size = "2",
+ }
+ },
+ },
+
+ },
+ capabilities = capabilities,
}
- })
- end,
- settings = {
- Lua = {}
- },
- capabilities = capabilities,
- }
- require'lspconfig'.tsserver.setup {
- filetypes = { 'typescript', 'typescriptreact', 'typescript.tsx' },
- capabilities = capabilities,
- flags = {
- debounce_text_changes = 150,
- },
- }
+ require 'lspconfig'.tsserver.setup {
+ filetypes = { 'typescript', 'typescriptreact', 'typescript.tsx' },
+ capabilities = capabilities,
+ flags = {
+ debounce_text_changes = 150,
+ },
+ }
+
+ require 'lspconfig'.pylsp.setup {
+ settings = {
+ pylsp = {
+ plugins = {
+ black = {
+ enabled = false,
+ },
+ ruff = {
+ enabled = true,
+ formatEnabled = true,
+ extendSelect = { 'I' },
+ format = { 'I' },
+ }
+ }
+ }
+ },
+ capabilities = capabilities,
+ flags = {
+ debounce_text_changes = 150,
+ },
+ }
- -- Use LspAttach autocommand to only map the following keys
- -- after the language server attaches to the current buffer
- vim.api.nvim_create_autocmd('LspAttach', {
- group = vim.api.nvim_create_augroup('UserLspConfig', {}),
- callback = function(ev)
- -- Enable completion triggered by <c-x><c-o>
- vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
+ -- Use LspAttach autocommand to only map the following keys
+ -- after the language server attaches to the current buffer
+ vim.api.nvim_create_autocmd('LspAttach', {
+ group = vim.api.nvim_create_augroup('UserLspConfig', {}),
+ callback = function(ev)
+ -- Enable completion triggered by <c-x><c-o>
+ vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
- local opts = { buffer = ev.buf }
- vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', { noremap = true })
- vim.keymap.set('x', '<leader>f', '<cmd>lua vim.lsp.buf.range_formatting()<CR>', {})
- vim.keymap.set('n', '<leader>f', function()
- vim.lsp.buf.format { async = true }
- end, opts)
+ local opts = { buffer = ev.buf }
+ vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', { noremap = true })
+ vim.keymap.set('v', '<leader>f', vim.lsp.buf.format, { noremap = true, silent = true })
+ vim.keymap.set('n', '<leader>f', function()
+ vim.lsp.buf.format { async = true }
+ end, opts)
+ end,
+ })
end,
- })
- end,
- },
+ },
}