From 33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 20 Aug 2023 23:38:05 +0300 Subject: nvim: nvim-ufo, bunch of fixes --- .config/nvim/lua/plugins/indent-blankline.lua | 2 +- .config/nvim/lua/plugins/lsp.lua | 18 +------ .config/nvim/lua/plugins/lualine.lua | 63 +++++++++++----------- .config/nvim/lua/plugins/nvim-ufo.lua | 78 +++++++++++++++++++++++++++ .config/nvim/lua/plugins/treesitter.lua | 20 +++++-- .config/nvim/lua/plugins/vim-illuminate.lua | 16 ++++++ .config/nvim/lua/plugins/vimwiki.lua | 1 + 7 files changed, 148 insertions(+), 50 deletions(-) create mode 100644 .config/nvim/lua/plugins/nvim-ufo.lua create mode 100644 .config/nvim/lua/plugins/vim-illuminate.lua (limited to '.config/nvim/lua/plugins') diff --git a/.config/nvim/lua/plugins/indent-blankline.lua b/.config/nvim/lua/plugins/indent-blankline.lua index 42e5c62..0906298 100644 --- a/.config/nvim/lua/plugins/indent-blankline.lua +++ b/.config/nvim/lua/plugins/indent-blankline.lua @@ -4,7 +4,7 @@ return { init = function() vim.opt.list = true end, - config = { + opts = { show_current_context = true, char = "┊", buftype_exclude = {"terminal"}, diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index d03d9af..8444f4b 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -60,7 +60,7 @@ return { vim.diagnostic.config(config) -- this function gets run when an lsp connects to a particular buffer. - local on_attach = function(client, bufnr) + local on_attach = function(_, bufnr) map = require("helpers.keys").lsp_map map("lr", vim.lsp.buf.rename, bufnr, "lsp: rename symbol") @@ -81,11 +81,6 @@ return { end, { desc = "lsp: format current buffer" }) map("fm", "Format", bufnr, "lsp: format current buffer") - - -- Attach and configure vim-illuminate - -- apparently this is deprecated - -- https://github.com/RRethy/vim-illuminate/issues/111 - require("illuminate").on_attach(client) end -- nvim-cmp supports additional completion capabilities, so broadcast that to servers @@ -211,7 +206,7 @@ return { { "j-hui/fidget.nvim", tag = "legacy", - event = "LspAttach", + event = "VeryLazy", opts = { text = { spinner = "triangle", @@ -224,13 +219,4 @@ return { "simrat39/rust-tools.nvim", event = "LspAttach", }, - -- { - -- "RRethy/vim-illuminate", - -- opts = { - -- filetypes_denylist = { - -- 'NvimTree', - -- 'fugitive', - -- }, - -- }, - -- }, } diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index c528b69..0da0b89 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -1,45 +1,48 @@ +local function lualine_spell() + if vim.wo.spell then + return "spell" + else + return + end +end + +local conditions = { + spell_on = function () + return vim.wo.spell + end, + filetype_is_tex = function() + return vim.bo.filetype == "tex" + end +} + +-- https://www.reddit.com/r/neovim/comments/u2uc4p/your_lualine_custom_features/i4muvp6/ +-- override 'encoding': don't display if encoding is utf-8. +local encoding = function() + local ret, _ = vim.bo.fenc:gsub("^utf%-8$", "") + return ret +end + +-- fileformat: don't display if &ff is unix. +local fileformat = function() + local ret, _ = vim.bo.fileformat:gsub("^unix$", "") + return ret +end + return { "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, config = function() - local function lualine_spell() - if vim.wo.spell then - return "spell" - else - return - end - end - - local conditions = { - spell_on = function () - return vim.wo.spell - end, - filetype_is_tex = function() - return vim.bo.filetype == "tex" - end - } - - -- https://www.reddit.com/r/neovim/comments/u2uc4p/your_lualine_custom_features/i4muvp6/ - -- override 'encoding': don't display if encoding is utf-8. - local encoding = function() - local ret, _ = vim.bo.fenc:gsub("^utf%-8$", "") - return ret - end - - -- fileformat: don't display if &ff is unix. - local fileformat = function() - local ret, _ = vim.bo.fileformat:gsub("^unix$", "") - return ret - end - require("lualine").setup({ options = { icons_enabled = true, theme = "catppuccin", section_separators = { left = '', right = '' }, component_separators = { left = '', right = '' }, + disabled_filetypes = { + "NvimTree", + }, }, sections = { lualine_a = {{'mode', fmt = string.lower}}, diff --git a/.config/nvim/lua/plugins/nvim-ufo.lua b/.config/nvim/lua/plugins/nvim-ufo.lua new file mode 100644 index 0000000..a3d69ba --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-ufo.lua @@ -0,0 +1,78 @@ +return { + { + "kevinhwang91/nvim-ufo", + event = "BufEnter", + keys = { + { + "zR", + function() + require("ufo").openAllFolds() + end, + desc = "ufo: open all folds", + }, + { + "zM", + function() + require("ufo").closeAllFolds() + end, + desc = "ufo: close all folds", + }, + { + "zr", + function() + require("ufo").openFoldsExceptKinds() + end, + desc = "ufo: open folds except kinds", + }, + { + "zm", + function() + require("ufo").closeFoldsWith() + end, + desc = "ufo: close folds with" + }, + { + "zp", + function() + require("ufo").peekFoldedLinesUnderCursor() + end, + desc = "ufo: peek fold" + }, + }, + dependencies = { + "kevinhwang91/promise-async", + }, + opts = { + preview = { + mappings = { + scrollB = "", + scrollF = "", + scrollU = "", + scrollD = "", + }, + }, + provider_selector = function(_, filetype, buftype) + local function handleFallbackException(bufnr, err, providerName) + if type(err) == "string" and err:match("UfoFallbackException") then + return require("ufo").getFolds(bufnr, providerName) + else + return require("promise").reject(err) + end + end + + return (filetype == "" or buftype == "nofile") and + "indent" -- only use indent until a file is opened + or function(bufnr) + return require("ufo") + .getFolds(bufnr, "lsp") + :catch(function(err) + return handleFallbackException(bufnr, err, "treesitter") + end) + :catch(function(err) + return handleFallbackException(bufnr, err, "indent") + end) + end + end, + }, + } +} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index c454b48..c462ec8 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -9,8 +9,22 @@ return { }, config = function() require("nvim-treesitter.configs").setup({ - ensure_installed = { "bash", "bibtex", "c", "cpp", "css", "fish", "http", "latex", "lua", "python", "rust", "vim" }, - ignore_install = { }, + ensure_installed = { + "bash", + "bibtex", + "c", + "cpp", + "css", + "fish", + "http", + "latex", + "lua", + "python", + "rust", + "toml", + "vim", + }, + ignore_install = {}, auto_install = true, sync_install = false, highlight = { @@ -66,7 +80,7 @@ return { }, }, }, - modules = { }, + modules = {}, }) end, }, diff --git a/.config/nvim/lua/plugins/vim-illuminate.lua b/.config/nvim/lua/plugins/vim-illuminate.lua new file mode 100644 index 0000000..451ffdb --- /dev/null +++ b/.config/nvim/lua/plugins/vim-illuminate.lua @@ -0,0 +1,16 @@ +return { + { + "RRethy/vim-illuminate", + event = "BufEnter", + opts = { + filetypes_denylist = { + "NvimTree", + "fugitive", + "TelescopePrompt" + }, + }, + config = function(_, opts) + require("illuminate").configure(opts) + end, + }, +} diff --git a/.config/nvim/lua/plugins/vimwiki.lua b/.config/nvim/lua/plugins/vimwiki.lua index 11d4c2b..352c01a 100644 --- a/.config/nvim/lua/plugins/vimwiki.lua +++ b/.config/nvim/lua/plugins/vimwiki.lua @@ -15,6 +15,7 @@ return { auto_tags = 1 } } + vim.g.vimwiki_global_ext = 0 vim.g.vimwiki_hl_headers = 1 local map = require("helpers.keys").map -- cgit v1.2.3-70-g09d2