From 612ec0cbe6a37cc23815f0408fb4a774597b595c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 10 Sep 2022 13:39:45 +0200 Subject: [PATCH] some more fixes for different nvim versions --- lua/my_options.lua | 21 --------------------- lua/setup/lualine.lua | 38 +++++++++++++++++++++++++++++++++----- lua/setup/my_lspconfig.lua | 6 +++++- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/lua/my_options.lua b/lua/my_options.lua index 73e138d..dc33c6b 100644 --- a/lua/my_options.lua +++ b/lua/my_options.lua @@ -47,7 +47,6 @@ opt.expandtab= true opt.smartindent= true opt.title = true opt.titlestring = '%{getcwd()} - %t' -opt.laststatus = 3 -- go to previous/next line with h,l,left arrow and right arrow -- when cursor reaches end/beginning of line @@ -61,23 +60,3 @@ opt.foldlevel = 20 opt.foldmethod = 'expr' opt.foldexpr = 'nvim_treesitter#foldexpr()' -if vim.version().minor >= 8 then - local function status_line() - local file_name = "%-.32t" - local modified = " %-m" - local right_align = "%=" - local line_no = "%10([%l/%L%)]" - local pct_thru_file = "%5p%%" - - return string.format( - "%s%s%s%s%s", - file_name, - modified, - right_align, - line_no, - pct_thru_file - ) - end - - opt.winbar = status_line() -end diff --git a/lua/setup/lualine.lua b/lua/setup/lualine.lua index 2ae1bd9..ebe45d2 100644 --- a/lua/setup/lualine.lua +++ b/lua/setup/lualine.lua @@ -1,6 +1,34 @@ +if vim.version().minor >= 8 then + local function status_line() + local file_name = "%-.32t" + local modified = " %-m" + local right_align = "%=" + local line_no = "%10([%l/%L%)]" + local pct_thru_file = "%5p%%" -require('lualine').setup({ - options = { theme = 'gruvbox-baby' }, - sections = { lualine_c = { 'getcwd' } }, - inactive_sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } }, -}) + return string.format( + "%s%s%s%s%s", + file_name, + modified, + right_align, + line_no, + pct_thru_file + ) + end + + vim.opt.laststatus = 3 + vim.opt.winbar = status_line() + require('lualine').setup({ + options = { theme = 'gruvbox-baby' }, + sections = { lualine_c = { 'getcwd' } }, + inactive_sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } }, + globalstatus = true, + }) +else + require('lualine').setup({ + options = { theme = 'gruvbox-baby' }, + sections = { lualine_c = { 'filename' } }, + globalstatus = false, + -- inactive_sections = { lualine_c = { 'filename' } }, + }) +end diff --git a/lua/setup/my_lspconfig.lua b/lua/setup/my_lspconfig.lua index 53e069b..98bd57f 100644 --- a/lua/setup/my_lspconfig.lua +++ b/lua/setup/my_lspconfig.lua @@ -63,7 +63,11 @@ local on_attach = function(client, bufnr) -- Set some keybinds conditional on server capabilities if client.server_capabilities.documentFormattingProvider then - vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) + if vim.version().minor >= 8 then + vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) + else + vim.keymap.set('n', 'f', vim.lsp.buf.formatting, opts) + end end if client.server_capabilities.documentRangeFormattingProvider then vim.keymap.set('v', 'f', vim.lsp.buf.range_formatting, opts)