From ac7583b0fbaa84c04164b3746b099407d9ff255e Mon Sep 17 00:00:00 2001 From: Michaël Ball Date: Fri, 23 Aug 2024 09:36:12 +0100 Subject: Neovim changes --- neovim/.config/nvim/init.lua | 2 +- neovim/.config/nvim/lua/config/colourscheme.lua | 2 +- neovim/.config/nvim/lua/config/galaxyline.lua | 201 +++++++++++++++++++++ neovim/.config/nvim/lua/config/lazy.lua | 4 +- neovim/.config/nvim/lua/plugins/galaxyline.lua | 36 +++- neovim/.config/nvim/lua/plugins/goyo.lua | 2 +- .../.config/nvim/lua/plugins/indent_blankline.lua | 2 +- neovim/.config/nvim/lua/plugins/lspsaga.lua | 3 + neovim/.config/nvim/lua/plugins/nvim_cmp.lua | 17 +- neovim/.config/nvim/lua/plugins/nvim_colorizer.lua | 9 + neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua | 15 +- neovim/.config/nvim/lua/plugins/tabby.lua | 27 ++- .../.config/nvim/lua/plugins/vim_jinja2_syntax.lua | 6 - neovim/.config/nvim/lua/plugins/vim_prettier.lua | 6 +- neovim/.config/nvim/lua/settings.lua | 1 + 15 files changed, 304 insertions(+), 29 deletions(-) create mode 100644 neovim/.config/nvim/lua/config/galaxyline.lua create mode 100644 neovim/.config/nvim/lua/plugins/nvim_colorizer.lua delete mode 100644 neovim/.config/nvim/lua/plugins/vim_jinja2_syntax.lua diff --git a/neovim/.config/nvim/init.lua b/neovim/.config/nvim/init.lua index b3979ea..3486285 100644 --- a/neovim/.config/nvim/init.lua +++ b/neovim/.config/nvim/init.lua @@ -1,3 +1,3 @@ -require('config.lazy') require('settings') +require('config.lazy') require('config.colourscheme') diff --git a/neovim/.config/nvim/lua/config/colourscheme.lua b/neovim/.config/nvim/lua/config/colourscheme.lua index edba16f..56ae5b6 100644 --- a/neovim/.config/nvim/lua/config/colourscheme.lua +++ b/neovim/.config/nvim/lua/config/colourscheme.lua @@ -1,4 +1,4 @@ -local colorscheme = "xcode" +local colorscheme = "onedark" vim.o.background = "light" local ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) if not ok then diff --git a/neovim/.config/nvim/lua/config/galaxyline.lua b/neovim/.config/nvim/lua/config/galaxyline.lua new file mode 100644 index 0000000..6204f4f --- /dev/null +++ b/neovim/.config/nvim/lua/config/galaxyline.lua @@ -0,0 +1,201 @@ +local gl = require('galaxyline') +local colors = { + yellow = vim.g.terminal_color_11, + cyan = vim.g.terminal_color_14, + darkblue = vim.g.terminal_color_4, + green = vim.g.terminal_color_10, + orange = vim.g.terminal_color_3, + violet = vim.g.terminal_color_5, + magenta = vim.g.terminal_color_13, + blue = vim.g.terminal_color_12, + red = vim.g.terminal_color_9, +} +local condition = require('galaxyline.condition') +local gls = gl.section +local lsp = require('galaxyline.provider_lsp') +gl.short_line_list = { 'nerdtree', 'NeogitStatus', 'vim-plug', 'lspsagaoutline', 'neo-tree', 'sagaoutline' } + +gls.left[1] = { + RainbowBlue = { + 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()]) + return ' ' + end, + highlight = { colors.red, 'StatusLine', 'bold' }, + }, +} + +gls.left[3] = { + FileSize = { + provider = 'FileSize', + condition = condition.buffer_not_empty, + highlight = { 'StatusLine', 'StatusLine' }, + } +} +gls.left[4] = { + FileIcon = { + provider = 'FileIcon', + highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, 'StatusLine' }, + }, +} + +gls.left[5] = { + FileName = { + provider = 'FileName', + condition = condition.buffer_not_empty, + highlight = { colors.magenta, 'StatusLine', 'bold' } + } +} + +gls.left[6] = { + LineInfo = { + provider = 'LineColumn', + separator = ' ', + separator_highlight = { 'NONE', 'StatusLine' }, + highlight = { 'NONE', 'StatusLine' }, + }, +} + +gls.left[7] = { + PerCent = { + provider = 'LinePercent', + separator = ' ', + separator_highlight = { 'NONE', 'StatusLine' }, + highlight = { 'NONE', 'StatusLine', 'bold' }, + } +} + +gls.left[8] = { + DiagnosticError = { + provider = 'DiagnosticError', + icon = '  ', + highlight = { colors.red, 'StatusLine' } + } +} +gls.left[9] = { + DiagnosticWarn = { + provider = 'DiagnosticWarn', + icon = '  ', + highlight = { colors.yellow, 'StatusLine' }, + } +} + +gls.left[10] = { + DiagnosticHint = { + provider = 'DiagnosticHint', + icon = '  ', + highlight = { colors.cyan, 'StatusLine' }, + } +} + +gls.left[11] = { + DiagnosticInfo = { + provider = 'DiagnosticInfo', + icon = '  ', + highlight = { colors.blue, 'StatusLine' }, + } +} + +gls.mid[1] = { + ShowLspClient = { + provider = 'GetLspClient', + condition = function() + local tbl = { ['dashboard'] = true, [''] = true } + if tbl[vim.bo.filetype] then + return false + elseif lsp.get_lsp_client() == 'No Active Lsp' then + return false + end + return true + end, + icon = '⚙ LSP:', + highlight = { colors.cyan, 'StatusLine', 'bold' } + } +} + +gls.right[1] = { + GitIcon = { + provider = function() return '  ' end, + condition = condition.check_git_workspace, + separator = ' ', + separator_highlight = { 'NONE', 'StatusLine' }, + highlight = { colors.violet, 'StatusLine', 'bold' }, + } +} + +gls.right[2] = { + GitBranch = { + provider = 'GitBranch', + condition = condition.check_git_workspace, + highlight = { colors.violet, 'StatusLine', 'bold' }, + } +} + +gls.right[3] = { + DiffAdd = { + provider = 'DiffAdd', + condition = condition.hide_in_width, + icon = ' +', + highlight = { colors.green, 'StatusLine' }, + } +} +gls.right[4] = { + DiffModified = { + provider = 'DiffModified', + condition = condition.hide_in_width, + icon = ' ±', + highlight = { colors.orange, 'StatusLine' }, + } +} +gls.right[5] = { + DiffRemove = { + provider = 'DiffRemove', + condition = condition.hide_in_width, + icon = ' -', + highlight = { colors.red, 'StatusLine' }, + } +} + +gls.right[6] = { + RainbowBlue = { + provider = function() return ' ▊' end, + highlight = { colors.blue, 'StatusLine' } + }, +} + +gls.short_line_left[1] = {} + +gls.short_line_left[2] = {} + +gls.short_line_right[1] = {} diff --git a/neovim/.config/nvim/lua/config/lazy.lua b/neovim/.config/nvim/lua/config/lazy.lua index a109cd0..2d9b70f 100644 --- a/neovim/.config/nvim/lua/config/lazy.lua +++ b/neovim/.config/nvim/lua/config/lazy.lua @@ -29,7 +29,7 @@ require("lazy").setup({ }, -- Configure any other settings here. See the documentation for more details. -- colorscheme that will be used when installing plugins. - install = { colorscheme = { "xcode" }, missing = true }, + install = { colorscheme = { "onedark" }, missing = true }, -- automatically check for plugin updates - checker = { enabled = false }, + checker = { enabled = true, notify = false }, }) diff --git a/neovim/.config/nvim/lua/plugins/galaxyline.lua b/neovim/.config/nvim/lua/plugins/galaxyline.lua index 1143b60..ad62a87 100644 --- a/neovim/.config/nvim/lua/plugins/galaxyline.lua +++ b/neovim/.config/nvim/lua/plugins/galaxyline.lua @@ -6,6 +6,15 @@ return { { 'nvim-tree/nvim-web-devicons', }, + { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + lazy = false, + opts = { + term_colors = true, + }, + }, { 'navarasu/onedark.nvim', lazy = false, @@ -14,19 +23,30 @@ return { style = 'light', }, }, + { + 'nyoom-engineering/oxocarbon.nvim', + lazy = false, + priority = 1000, + }, + { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + opts = {}, + }, { 'lunacookies/vim-colors-xcode', lazy = false, priority = 1000, --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, - --}) + --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 = { { diff --git a/neovim/.config/nvim/lua/plugins/goyo.lua b/neovim/.config/nvim/lua/plugins/goyo.lua index dba0f39..bfe797a 100644 --- a/neovim/.config/nvim/lua/plugins/goyo.lua +++ b/neovim/.config/nvim/lua/plugins/goyo.lua @@ -37,7 +37,7 @@ return { vim.opt.showcmd = true vim.opt.scrolloff = 5 dofile(script_path() .. '../config/galaxyline.lua') - vim.opt.laststatus = 2 + vim.opt.laststatus = 3 vim.cmd('Limelight!') vim.cmd('VimRToggleFullscreen') end diff --git a/neovim/.config/nvim/lua/plugins/indent_blankline.lua b/neovim/.config/nvim/lua/plugins/indent_blankline.lua index 5feea4d..a59a3a6 100644 --- a/neovim/.config/nvim/lua/plugins/indent_blankline.lua +++ b/neovim/.config/nvim/lua/plugins/indent_blankline.lua @@ -6,7 +6,7 @@ return { indent = { char = '▏' }, scope = { enabled = true, - char = '▎' + -- char = '▎' }, }, }, diff --git a/neovim/.config/nvim/lua/plugins/lspsaga.lua b/neovim/.config/nvim/lua/plugins/lspsaga.lua index f9414e8..53bff94 100644 --- a/neovim/.config/nvim/lua/plugins/lspsaga.lua +++ b/neovim/.config/nvim/lua/plugins/lspsaga.lua @@ -9,6 +9,9 @@ return { symbol_in_winbar = { respect_root = true, }, + lightbulb = { + virtual_text = false, + } }, keys = { { "gh", "Lspsaga finder", desc = "Lspsaga finder" }, diff --git a/neovim/.config/nvim/lua/plugins/nvim_cmp.lua b/neovim/.config/nvim/lua/plugins/nvim_cmp.lua index ad626ef..29ef7b6 100644 --- a/neovim/.config/nvim/lua/plugins/nvim_cmp.lua +++ b/neovim/.config/nvim/lua/plugins/nvim_cmp.lua @@ -31,11 +31,14 @@ return { dependencies = { 'hrsh7th/vim-vsnip', }, - } + }, + { + 'onsails/lspkind.nvim', + }, }, config = function () local cmp = require('cmp') - + local lspkind = require('lspkind') cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine @@ -62,6 +65,16 @@ return { }, { { name = 'tmux' }, }), + formatting = { + format = lspkind.cmp_format({ + mode = 'symbol', -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + -- can also be a function to dynamically calculate max width such as + -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, + ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + show_labelDetails = true, -- show labelDetails in menu. Disabled by default + }) + }, }) -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). diff --git a/neovim/.config/nvim/lua/plugins/nvim_colorizer.lua b/neovim/.config/nvim/lua/plugins/nvim_colorizer.lua new file mode 100644 index 0000000..28a8317 --- /dev/null +++ b/neovim/.config/nvim/lua/plugins/nvim_colorizer.lua @@ -0,0 +1,9 @@ +return { + 'norcalli/nvim-colorizer.lua', + main = 'colorizer', + opts = { + css = { + css = true, + }, + }, +} diff --git a/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua b/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua index 75ce1ac..5c54a20 100644 --- a/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua +++ b/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua @@ -8,8 +8,8 @@ return { 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", "dockerls", "gopls", "html", "htmx", "jsonls", "marksman", - "ruff", "rust_analyzer", "yamlls" } + local servers = { "bashls", "clangd", "cssls", "dockerls", "gopls", "htmx", "jsonls", "marksman", + "phpactor", "psalm", "ruff", "rust_analyzer", "taplo", "yamlls" } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { capabilities = capabilities, @@ -61,6 +61,14 @@ return { capabilities = capabilities, } + require 'lspconfig'.html.setup { + filetypes = { 'html', 'htmldjango' }, + capabilities = capabilities, + flags = { + debounce_text_changes = 150, + }, + } + require 'lspconfig'.tsserver.setup { filetypes = { 'typescript', 'typescriptreact', 'typescript.tsx' }, capabilities = capabilities, @@ -88,6 +96,9 @@ return { pyflakes = { enabled = false, }, + pylsp_mypy = { + enabled = true, + }, ruff = { enabled = false, }, diff --git a/neovim/.config/nvim/lua/plugins/tabby.lua b/neovim/.config/nvim/lua/plugins/tabby.lua index b989ae5..0aa271e 100644 --- a/neovim/.config/nvim/lua/plugins/tabby.lua +++ b/neovim/.config/nvim/lua/plugins/tabby.lua @@ -4,16 +4,23 @@ return { dependencies = { 'nvim-tree/nvim-web-devicons', }, - config = function () + config = function() local theme = { fill = 'TabLineFill', -- Also you can do this: fill = { fg='#f2e9de', bg='#907aa9', style='italic' } head = 'TabLine', current_tab = 'TabLineSel', tab = 'TabLine', + current_win = 'TabLineSel', win = 'TabLine', tail = 'TabLine', } + require('tabby').setup({ + option = { + theme = theme, + nerdfont = true, + }, + }) require('tabby.tabline').set(function(line) return { { @@ -23,7 +30,6 @@ return { local hl = tab.is_current() and theme.current_tab or theme.tab return { line.sep('', hl, theme.fill), - tab.is_current() and '' or '', tab.number(), tab.name(), tab.close_btn(''), @@ -32,10 +38,25 @@ return { margin = ' ', } end), + line.spacer(), + line.wins_in_tab(line.api.get_current_tab()).foreach(function(win) + local hl = win.is_current() and theme.current_win or theme.win + return { + line.sep('', hl, theme.fill), + win.file_icon(), + win.buf_name(), + line.sep('', hl, theme.fill), + hl = hl, + margin = ' ', + } + end), + { + line.sep('', theme.tail, theme.fill), + }, hl = theme.fill, } end) end, - cond = function() return vim.fn.has('gui_running') == 0 end, + --cond = function() return vim.fn.has('gui_running') == 0 end, }, } diff --git a/neovim/.config/nvim/lua/plugins/vim_jinja2_syntax.lua b/neovim/.config/nvim/lua/plugins/vim_jinja2_syntax.lua deleted file mode 100644 index eed3d6a..0000000 --- a/neovim/.config/nvim/lua/plugins/vim_jinja2_syntax.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - { - 'Glench/Vim-Jinja2-Syntax', - ft = 'jinja', - }, -} diff --git a/neovim/.config/nvim/lua/plugins/vim_prettier.lua b/neovim/.config/nvim/lua/plugins/vim_prettier.lua index f5be9c5..f4a6f8b 100644 --- a/neovim/.config/nvim/lua/plugins/vim_prettier.lua +++ b/neovim/.config/nvim/lua/plugins/vim_prettier.lua @@ -1,8 +1,10 @@ return { { 'prettier/vim-prettier', + ft = { 'css', 'javascript', 'javascriptreact', 'json', 'markdown', 'scss', 'typescript', 'typescriptreact', 'yaml' }, keys = { - { "p", "PrettierAsync", desc="Run prettier" } - } + { "p", "PrettierAsync", desc = "Run prettier" }, + { "p", "'<,'>PrettierFragment", mode = "v", desc = "Run prettier on selection" }, + }, }, } diff --git a/neovim/.config/nvim/lua/settings.lua b/neovim/.config/nvim/lua/settings.lua index 98d9a01..4d3c601 100644 --- a/neovim/.config/nvim/lua/settings.lua +++ b/neovim/.config/nvim/lua/settings.lua @@ -37,6 +37,7 @@ vim.opt.writebackup = false vim.opt.updatetime = 300 vim.opt.shortmess:append 'c' vim.opt.signcolumn = 'yes' +vim.opt.laststatus = 3 -- Autocommands -- cgit v1.2.3