diff options
author | Yigit Sever | 2023-08-20 23:38:05 +0300 |
---|---|---|
committer | Yigit Sever | 2023-08-20 23:38:05 +0300 |
commit | 33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4 (patch) | |
tree | 029c93b57f88f36d4b8cf4a389a906faae535e79 /.config/nvim/lua/plugins | |
parent | a986d07da86e951180b5eea7dfd20d0da46e0cd8 (diff) | |
download | dotfiles-33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4.tar.gz dotfiles-33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4.tar.bz2 dotfiles-33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4.zip |
nvim: nvim-ufo, bunch of fixes
Diffstat (limited to '.config/nvim/lua/plugins')
-rw-r--r-- | .config/nvim/lua/plugins/indent-blankline.lua | 2 | ||||
-rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 18 | ||||
-rw-r--r-- | .config/nvim/lua/plugins/lualine.lua | 63 | ||||
-rw-r--r-- | .config/nvim/lua/plugins/nvim-ufo.lua | 78 | ||||
-rw-r--r-- | .config/nvim/lua/plugins/treesitter.lua | 20 | ||||
-rw-r--r-- | .config/nvim/lua/plugins/vim-illuminate.lua | 16 | ||||
-rw-r--r-- | .config/nvim/lua/plugins/vimwiki.lua | 1 |
7 files changed, 148 insertions, 50 deletions
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 { | |||
4 | init = function() | 4 | init = function() |
5 | vim.opt.list = true | 5 | vim.opt.list = true |
6 | end, | 6 | end, |
7 | config = { | 7 | opts = { |
8 | show_current_context = true, | 8 | show_current_context = true, |
9 | char = "┊", | 9 | char = "┊", |
10 | buftype_exclude = {"terminal"}, | 10 | 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 { | |||
60 | vim.diagnostic.config(config) | 60 | vim.diagnostic.config(config) |
61 | 61 | ||
62 | -- this function gets run when an lsp connects to a particular buffer. | 62 | -- this function gets run when an lsp connects to a particular buffer. |
63 | local on_attach = function(client, bufnr) | 63 | local on_attach = function(_, bufnr) |
64 | map = require("helpers.keys").lsp_map | 64 | map = require("helpers.keys").lsp_map |
65 | 65 | ||
66 | map("<leader>lr", vim.lsp.buf.rename, bufnr, "lsp: rename symbol") | 66 | map("<leader>lr", vim.lsp.buf.rename, bufnr, "lsp: rename symbol") |
@@ -81,11 +81,6 @@ return { | |||
81 | end, { desc = "lsp: format current buffer" }) | 81 | end, { desc = "lsp: format current buffer" }) |
82 | 82 | ||
83 | map("<leader>fm", "<cmd>Format<cr>", bufnr, "lsp: format current buffer") | 83 | map("<leader>fm", "<cmd>Format<cr>", bufnr, "lsp: format current buffer") |
84 | |||
85 | -- Attach and configure vim-illuminate | ||
86 | -- apparently this is deprecated | ||
87 | -- https://github.com/RRethy/vim-illuminate/issues/111 | ||
88 | require("illuminate").on_attach(client) | ||
89 | end | 84 | end |
90 | 85 | ||
91 | -- nvim-cmp supports additional completion capabilities, so broadcast that to servers | 86 | -- nvim-cmp supports additional completion capabilities, so broadcast that to servers |
@@ -211,7 +206,7 @@ return { | |||
211 | { | 206 | { |
212 | "j-hui/fidget.nvim", | 207 | "j-hui/fidget.nvim", |
213 | tag = "legacy", | 208 | tag = "legacy", |
214 | event = "LspAttach", | 209 | event = "VeryLazy", |
215 | opts = { | 210 | opts = { |
216 | text = { | 211 | text = { |
217 | spinner = "triangle", | 212 | spinner = "triangle", |
@@ -224,13 +219,4 @@ return { | |||
224 | "simrat39/rust-tools.nvim", | 219 | "simrat39/rust-tools.nvim", |
225 | event = "LspAttach", | 220 | event = "LspAttach", |
226 | }, | 221 | }, |
227 | -- { | ||
228 | -- "RRethy/vim-illuminate", | ||
229 | -- opts = { | ||
230 | -- filetypes_denylist = { | ||
231 | -- 'NvimTree', | ||
232 | -- 'fugitive', | ||
233 | -- }, | ||
234 | -- }, | ||
235 | -- }, | ||
236 | } | 222 | } |
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 @@ | |||
1 | local function lualine_spell() | ||
2 | if vim.wo.spell then | ||
3 | return "spell" | ||
4 | else | ||
5 | return | ||
6 | end | ||
7 | end | ||
8 | |||
9 | local conditions = { | ||
10 | spell_on = function () | ||
11 | return vim.wo.spell | ||
12 | end, | ||
13 | filetype_is_tex = function() | ||
14 | return vim.bo.filetype == "tex" | ||
15 | end | ||
16 | } | ||
17 | |||
18 | -- https://www.reddit.com/r/neovim/comments/u2uc4p/your_lualine_custom_features/i4muvp6/ | ||
19 | -- override 'encoding': don't display if encoding is utf-8. | ||
20 | local encoding = function() | ||
21 | local ret, _ = vim.bo.fenc:gsub("^utf%-8$", "") | ||
22 | return ret | ||
23 | end | ||
24 | |||
25 | -- fileformat: don't display if &ff is unix. | ||
26 | local fileformat = function() | ||
27 | local ret, _ = vim.bo.fileformat:gsub("^unix$", "") | ||
28 | return ret | ||
29 | end | ||
30 | |||
1 | return { | 31 | return { |
2 | "nvim-lualine/lualine.nvim", | 32 | "nvim-lualine/lualine.nvim", |
3 | dependencies = { | 33 | dependencies = { |
4 | "nvim-tree/nvim-web-devicons" | 34 | "nvim-tree/nvim-web-devicons" |
5 | }, | 35 | }, |
6 | config = function() | 36 | config = function() |
7 | local function lualine_spell() | ||
8 | if vim.wo.spell then | ||
9 | return "spell" | ||
10 | else | ||
11 | return | ||
12 | end | ||
13 | end | ||
14 | |||
15 | local conditions = { | ||
16 | spell_on = function () | ||
17 | return vim.wo.spell | ||
18 | end, | ||
19 | filetype_is_tex = function() | ||
20 | return vim.bo.filetype == "tex" | ||
21 | end | ||
22 | } | ||
23 | |||
24 | -- https://www.reddit.com/r/neovim/comments/u2uc4p/your_lualine_custom_features/i4muvp6/ | ||
25 | -- override 'encoding': don't display if encoding is utf-8. | ||
26 | local encoding = function() | ||
27 | local ret, _ = vim.bo.fenc:gsub("^utf%-8$", "") | ||
28 | return ret | ||
29 | end | ||
30 | |||
31 | -- fileformat: don't display if &ff is unix. | ||
32 | local fileformat = function() | ||
33 | local ret, _ = vim.bo.fileformat:gsub("^unix$", "") | ||
34 | return ret | ||
35 | end | ||
36 | |||
37 | require("lualine").setup({ | 37 | require("lualine").setup({ |
38 | options = { | 38 | options = { |
39 | icons_enabled = true, | 39 | icons_enabled = true, |
40 | theme = "catppuccin", | 40 | theme = "catppuccin", |
41 | section_separators = { left = '', right = '' }, | 41 | section_separators = { left = '', right = '' }, |
42 | component_separators = { left = '', right = '' }, | 42 | component_separators = { left = '', right = '' }, |
43 | disabled_filetypes = { | ||
44 | "NvimTree", | ||
45 | }, | ||
43 | }, | 46 | }, |
44 | sections = { | 47 | sections = { |
45 | lualine_a = {{'mode', fmt = string.lower}}, | 48 | 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 @@ | |||
1 | return { | ||
2 | { | ||
3 | "kevinhwang91/nvim-ufo", | ||
4 | event = "BufEnter", | ||
5 | keys = { | ||
6 | { | ||
7 | "zR", | ||
8 | function() | ||
9 | require("ufo").openAllFolds() | ||
10 | end, | ||
11 | desc = "ufo: open all folds", | ||
12 | }, | ||
13 | { | ||
14 | "zM", | ||
15 | function() | ||
16 | require("ufo").closeAllFolds() | ||
17 | end, | ||
18 | desc = "ufo: close all folds", | ||
19 | }, | ||
20 | { | ||
21 | "zr", | ||
22 | function() | ||
23 | require("ufo").openFoldsExceptKinds() | ||
24 | end, | ||
25 | desc = "ufo: open folds except kinds", | ||
26 | }, | ||
27 | { | ||
28 | "zm", | ||
29 | function() | ||
30 | require("ufo").closeFoldsWith() | ||
31 | end, | ||
32 | desc = "ufo: close folds with" | ||
33 | }, | ||
34 | { | ||
35 | "zp", | ||
36 | function() | ||
37 | require("ufo").peekFoldedLinesUnderCursor() | ||
38 | end, | ||
39 | desc = "ufo: peek fold" | ||
40 | }, | ||
41 | }, | ||
42 | dependencies = { | ||
43 | "kevinhwang91/promise-async", | ||
44 | }, | ||
45 | opts = { | ||
46 | preview = { | ||
47 | mappings = { | ||
48 | scrollB = "<C-b>", | ||
49 | scrollF = "<C-f>", | ||
50 | scrollU = "<C-u>", | ||
51 | scrollD = "<C-d>", | ||
52 | }, | ||
53 | }, | ||
54 | provider_selector = function(_, filetype, buftype) | ||
55 | local function handleFallbackException(bufnr, err, providerName) | ||
56 | if type(err) == "string" and err:match("UfoFallbackException") then | ||
57 | return require("ufo").getFolds(bufnr, providerName) | ||
58 | else | ||
59 | return require("promise").reject(err) | ||
60 | end | ||
61 | end | ||
62 | |||
63 | return (filetype == "" or buftype == "nofile") and | ||
64 | "indent" -- only use indent until a file is opened | ||
65 | or function(bufnr) | ||
66 | return require("ufo") | ||
67 | .getFolds(bufnr, "lsp") | ||
68 | :catch(function(err) | ||
69 | return handleFallbackException(bufnr, err, "treesitter") | ||
70 | end) | ||
71 | :catch(function(err) | ||
72 | return handleFallbackException(bufnr, err, "indent") | ||
73 | end) | ||
74 | end | ||
75 | end, | ||
76 | }, | ||
77 | } | ||
78 | } | ||
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 { | |||
9 | }, | 9 | }, |
10 | config = function() | 10 | config = function() |
11 | require("nvim-treesitter.configs").setup({ | 11 | require("nvim-treesitter.configs").setup({ |
12 | ensure_installed = { "bash", "bibtex", "c", "cpp", "css", "fish", "http", "latex", "lua", "python", "rust", "vim" }, | 12 | ensure_installed = { |
13 | ignore_install = { }, | 13 | "bash", |
14 | "bibtex", | ||
15 | "c", | ||
16 | "cpp", | ||
17 | "css", | ||
18 | "fish", | ||
19 | "http", | ||
20 | "latex", | ||
21 | "lua", | ||
22 | "python", | ||
23 | "rust", | ||
24 | "toml", | ||
25 | "vim", | ||
26 | }, | ||
27 | ignore_install = {}, | ||
14 | auto_install = true, | 28 | auto_install = true, |
15 | sync_install = false, | 29 | sync_install = false, |
16 | highlight = { | 30 | highlight = { |
@@ -66,7 +80,7 @@ return { | |||
66 | }, | 80 | }, |
67 | }, | 81 | }, |
68 | }, | 82 | }, |
69 | modules = { }, | 83 | modules = {}, |
70 | }) | 84 | }) |
71 | end, | 85 | end, |
72 | }, | 86 | }, |
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 @@ | |||
1 | return { | ||
2 | { | ||
3 | "RRethy/vim-illuminate", | ||
4 | event = "BufEnter", | ||
5 | opts = { | ||
6 | filetypes_denylist = { | ||
7 | "NvimTree", | ||
8 | "fugitive", | ||
9 | "TelescopePrompt" | ||
10 | }, | ||
11 | }, | ||
12 | config = function(_, opts) | ||
13 | require("illuminate").configure(opts) | ||
14 | end, | ||
15 | }, | ||
16 | } | ||
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 { | |||
15 | auto_tags = 1 | 15 | auto_tags = 1 |
16 | } | 16 | } |
17 | } | 17 | } |
18 | vim.g.vimwiki_global_ext = 0 | ||
18 | vim.g.vimwiki_hl_headers = 1 | 19 | vim.g.vimwiki_hl_headers = 1 |
19 | 20 | ||
20 | local map = require("helpers.keys").map | 21 | local map = require("helpers.keys").map |