Bläddra i källkod

move from vim-airline to nvim-lualine

Noah Vogt 1 dag sedan
förälder
incheckning
81ca85e29a

+ 2 - 1
dot-config/nvim/init.lua

@@ -18,7 +18,7 @@ require('plugins')
 
 -- 4. Load vimscript Plugin configurations
 local plug_confs = {
-  'emmet', 'sneak', 'airline',
+  'emmet', 'sneak',
   'startify', 'wilder', 'vcoolor', 'better-whitespace'
 }
 for _, conf in ipairs(plug_confs) do
@@ -35,6 +35,7 @@ require('refactoring-conf')
 require('gitsigns-conf')
 require('indent-blankline')
 require('whichkey')
+require('lualine-conf')
 require('colorizer').setup()
 
 -- 6. Load keybinds and autocommands

+ 38 - 0
dot-config/nvim/lua/lualine-conf.lua

@@ -0,0 +1,38 @@
+local lualine = require('lualine')
+
+-- Custom component for Wordcount (only text and markdown)
+local function wordcount()
+  if vim.bo.filetype == "markdown" or vim.bo.filetype == "text" then
+    return tostring(vim.fn.wordcount().words) .. " words"
+  else
+    return ""
+  end
+end
+
+-- Custom component for Gradle build status (vim-android)
+local function gradle_status()
+  if vim.fn.exists('*lightline#gradle#running') == 1 then
+    local status = vim.fn['lightline#gradle#running']()
+    if status and status ~= '' then
+      return status
+    end
+  end
+  return ""
+end
+
+lualine.setup({
+  options = {
+    theme = 'auto',
+    globalstatus = true,
+    component_separators = { left = '', right = ''},
+    section_separators = { left = '', right = ''},
+  },
+  sections = {
+    lualine_a = {'mode'},
+    lualine_b = {'branch', 'diff', 'diagnostics'},
+    lualine_c = {'filename'},
+    lualine_x = {gradle_status, 'encoding', 'fileformat', 'filetype'},
+    lualine_y = {'progress', wordcount},
+    lualine_z = {'location'}
+  },
+})

+ 5 - 3
dot-config/nvim/lua/plugins.lua

@@ -29,9 +29,11 @@ require("lazy").setup({
     cmd = { "CMakeGenerate", "CMakeBuild", "CMakeRun", "CMakeDebugTarget" },
   },
 
-  -- Airline
-  'vim-airline/vim-airline',
-  'vim-airline/vim-airline-themes',
+  -- Lualine
+  {
+    'nvim-lualine/lualine.nvim',
+    dependencies = { 'nvim-tree/nvim-web-devicons' }
+  },
 
   -- Automatically close pairs like (), {}, etc.
   {

+ 4 - 4
dot-config/nvim/lua/theme.lua

@@ -43,10 +43,10 @@ function M.sync_theme()
     vim.api.nvim_set_hl(0, 'SpellLocal', { undercurl = true, sp = '#ffff00' })
     vim.api.nvim_set_hl(0, 'SpellRare',  { undercurl = true, sp = '#ffff00' })
 
-    -- Force airline to refresh
-    vim.g.airline_theme = 'onedark'
-    if vim.fn.exists(':AirlineTheme') == 2 then
-        vim.cmd('AirlineTheme onedark')
+    -- Refresh lualine theme
+    local has_lualine, lualine = pcall(require, 'lualine')
+    if has_lualine then
+        lualine.setup({ options = { theme = 'auto' } })
     end
 
     -- Force a full redraw to fix background issues in some terminals

+ 0 - 18
dot-config/nvim/plug-conf/airline.vim

@@ -1,18 +0,0 @@
-" enable tabline
-" let g:airline#extensions#tabline#enabled = 1
-" let g:airline#extensions#tabline#left_sep = ''
-" let g:airline#extensions#tabline#left_alt_sep = ''
-" let g:airline#extensions#tabline#right_sep = ''
-" let g:airline#extensions#tabline#right_alt_sep = ''
-call airline#parts#define_function(
-   \ 'gradle-running',
-   \ 'lightline#gradle#running'
-   \)
-
-" enable powerline fonts
-let g:airline_powerline_fonts = 1
-let g:airline#extensions#wordcount#enabled = 1
-let g:airline_section_x = airline#section#create_right([
-   \ 'filetype',
-   \ 'gradle-running'
-   \])