From cdf067b6a0883341b2c4366ab69d0b5d72d92cfe Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Wed, 20 Sep 2023 22:55:38 +0200 Subject: [PATCH] feat(nvim): migrate to lualine.nvim --- nvimrc | 66 +++--------------------------------- vim/lua/lightline_config.lua | 55 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 62 deletions(-) create mode 100644 vim/lua/lightline_config.lua diff --git a/nvimrc b/nvimrc index 59b85d9..6eb66e3 100644 --- a/nvimrc +++ b/nvimrc @@ -234,69 +234,11 @@ nmap T :Files nmap b :Buffers nmap rg :Rg -" Lightline configuration: -packadd! lightline.vim " https://github.com/itchyny/lightline.vim.git -set laststatus=2 +" lualine.nvim +packadd! lualine.nvim " https://git.netflux.io/rob/lualine.nvim.git +packadd! nvim-web-devicons " https://github.com/nvim-tree/nvim-web-devicons.git -function! LightlineLSPErrorText() - let l:count = luaeval("vim.diagnostic.get(0, [[Error]])") - if l:count == 0 - return '' - endif - return l:count . 'E' -endfunction - -function! LightlineLSPWarningText() - let l:count = luaeval("vim.diagnostic.get(0, [[Warning]])") - if l:count == 0 - return '' - endif - return l:count . 'W' -endfunction - -function! LightlineLSPInformationText() - let l:count = luaeval("vim.diagnostic.get(0, [[Information]])") - if l:count == 0 - return '' - endif - return l:count . 'I' -endfunction - -let g:lightline = { - \ 'colorscheme': 'seoul256', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], - \ [ 'readonly', 'filename', 'modified' ], - \ [ 'gitbranch' ], ['lsperror', 'lspwarn', 'lspinfo' ] ], - \ 'right': [ ['lineinfo'], ['percent'], ['filetype'], ['gobuild'] ], - \ }, - \ 'component_function': { - \ 'gobuild': 'go#statusline#Show', - \ 'gitbranch': 'FugitiveStatusline', - \ }, - \ 'component_expand': { - \ 'lsperror': 'LightlineLSPErrorText', - \ 'lspwarn': 'LightlineLSPWarningText', - \ 'lspinfo': 'LightlineLSPInformationText', - \ }, - \ 'component_type': { - \ 'lsperror': 'error', - \ 'lspwarn': 'warning', - \ }, - \ 'mode_map': { - \ 'n' : 'N', - \ 'i' : 'I', - \ 'R' : 'R', - \ 'v' : 'V', - \ 'V' : 'V-LINE', - \ "\": 'V-BLOCK', - \ 'c' : 'C', - \ 's' : 'S', - \ 'S' : 'S-LINE', - \ "\": 'S-BLOCK', - \ 't': 'TERM', - \ }, -\ } +lua require "lightline_config" " vim-gitgutter configuration packadd! vim-gitgutter " https://github.com/airblade/vim-gitgutter.git diff --git a/vim/lua/lightline_config.lua b/vim/lua/lightline_config.lua new file mode 100644 index 0000000..a5bd708 --- /dev/null +++ b/vim/lua/lightline_config.lua @@ -0,0 +1,55 @@ +require("nvim-web-devicons").setup({}) + +local mode_map = { + NORMAL = "N", + INSERT = "I", + REPLACE = "R", + COMMAND = "C", + VISUAL = "v", + ["V-BLOCK"] = "V", + ["V-LINE"] = "V-LINE", +} + +require("lualine").setup({ + options = { + icons_enabled = false, + theme = "nord", + }, + sections = { + lualine_a = { + { + "mode", + fmt = function(mode) + return mode_map[mode] or mode + end, + }, + }, + lualine_b = { "filename" }, + lualine_c = { + "branch", + "diff", + { + "diagnostics", + sources = { "nvim_lsp" }, + always_visible = false, + symbols = { + error = function(count) + return count .. "E" + end, + warn = function(count) + return count .. "W" + end, + info = function(count) + return count .. "I" + end, + hint = function(count) + return count .. "H" + end, + }, + }, + }, + lualine_x = { "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, +})