summaryrefslogtreecommitdiffstats
path: root/.config/nvim
diff options
context:
space:
mode:
authorYigit Sever2023-08-20 23:38:05 +0300
committerYigit Sever2023-08-20 23:38:05 +0300
commit33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4 (patch)
tree029c93b57f88f36d4b8cf4a389a906faae535e79 /.config/nvim
parenta986d07da86e951180b5eea7dfd20d0da46e0cd8 (diff)
downloaddotfiles-33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4.tar.gz
dotfiles-33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4.tar.bz2
dotfiles-33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4.zip
nvim: nvim-ufo, bunch of fixes
Diffstat (limited to '.config/nvim')
-rw-r--r--.config/nvim/init.lua7
-rw-r--r--.config/nvim/lazy-lock.json2
-rw-r--r--.config/nvim/lua/core/keymaps.lua19
-rw-r--r--.config/nvim/lua/core/options.lua97
-rw-r--r--.config/nvim/lua/plugins/indent-blankline.lua2
-rw-r--r--.config/nvim/lua/plugins/lsp.lua18
-rw-r--r--.config/nvim/lua/plugins/lualine.lua63
-rw-r--r--.config/nvim/lua/plugins/nvim-ufo.lua78
-rw-r--r--.config/nvim/lua/plugins/treesitter.lua20
-rw-r--r--.config/nvim/lua/plugins/vim-illuminate.lua16
-rw-r--r--.config/nvim/lua/plugins/vimwiki.lua1
11 files changed, 211 insertions, 112 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index c273f36..eacfbf4 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -5,14 +5,11 @@
5-- │▘ ▘▝▀▘▝▀ ▘ ▀▘▘▝ ▘│ 5-- │▘ ▘▝▀▘▝▀ ▘ ▀▘▘▝ ▘│
6-- └──────────────────┘ 6-- └──────────────────┘
7 7
8-- handle plugins with lazy.nvim 8require("core.options")
9require("core.lazy")
10 9
11-- general neovim keymaps
12require("core.keymaps") 10require("core.keymaps")
13 11
14-- other options 12require("core.lazy")
15require("core.options")
16 13
17-- I have to clean this 14-- I have to clean this
18require('helpers.stale').setup{} 15require('helpers.stale').setup{}
diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json
index e96ed42..34a93f4 100644
--- a/.config/nvim/lazy-lock.json
+++ b/.config/nvim/lazy-lock.json
@@ -28,8 +28,10 @@
28 "nvim-tree.lua": { "branch": "master", "commit": "18c7a3119839adc4599d838726deae662859c8b2" }, 28 "nvim-tree.lua": { "branch": "master", "commit": "18c7a3119839adc4599d838726deae662859c8b2" },
29 "nvim-treesitter": { "branch": "master", "commit": "add1864bbf2d3b8e789ec6b4715bb5a4073e3b60" }, 29 "nvim-treesitter": { "branch": "master", "commit": "add1864bbf2d3b8e789ec6b4715bb5a4073e3b60" },
30 "nvim-treesitter-textobjects": { "branch": "master", "commit": "56272167a6dead91c47c02dbdbfe1ae5643c59f5" }, 30 "nvim-treesitter-textobjects": { "branch": "master", "commit": "56272167a6dead91c47c02dbdbfe1ae5643c59f5" },
31 "nvim-ufo": { "branch": "main", "commit": "aebd36bf5447862671356fcd5d4a8708ce6c9470" },
31 "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, 32 "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" },
32 "plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" }, 33 "plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" },
34 "promise-async": { "branch": "main", "commit": "e94f35161b8c5d4a4ca3b6ff93dd073eb9214c0e" },
33 "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, 35 "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" },
34 "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" }, 36 "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" },
35 "targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" }, 37 "targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" },
diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua
index b63156d..95e5fcd 100644
--- a/.config/nvim/lua/core/keymaps.lua
+++ b/.config/nvim/lua/core/keymaps.lua
@@ -12,12 +12,11 @@ map("c", "w!!", 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!<CR>'
12map("n", "Q", "gq", "format lines") 12map("n", "Q", "gq", "format lines")
13 13
14-- set formatprg to sentences, for prose 14-- set formatprg to sentences, for prose
15-- TODO: can we do this with vim.o.formatprg? 15map("n", "<Leader>fp", ":set formatprg=~/.local/bin/sentences<CR>", "switch to sentences formatprg", { silent = false })
16map("n", "<Leader>fp", "<cmd>set formatprg=~/.local/bin/sentences<CR>", "switch to sentences view", { silent = false })
17 16
18-- replace all is aliased to S. 17-- replace all is aliased to S.
19map("n", "S", ":s//g<Left><Left>", "replace all", { silent = false }) 18map("n", "<leader>S", ":%s//g<Left><Left>", "replace all", { silent = false })
20map("v", "S", ":s//g<Left><Left>", "replace all selection", { silent = false }) 19map("v", "<leader>S", ":s//g<Left><Left>", "replace all", { silent = false })
21 20
22-- jump to buffer 21-- jump to buffer
23map("n", "<Leader>b", "<cmd>ls<cr>:b<space>", "jump to buffer") 22map("n", "<Leader>b", "<cmd>ls<cr>:b<space>", "jump to buffer")
@@ -42,16 +41,16 @@ map("n", "<Leader>cd", "<cmd>lcd %:p:h<CR>:pwd<CR>", "cd to current buffer's pwd
42 41
43-- call CreatePaper on word below cursor 42-- call CreatePaper on word below cursor
44map("n", "<leader>np", 'gewi[[/papers/<ESC>Ea]]<ESC>bb:call CreatePaper(expand("<cword>"))<CR>', 43map("n", "<leader>np", 'gewi[[/papers/<ESC>Ea]]<ESC>bb:call CreatePaper(expand("<cword>"))<CR>',
45 "vimwiki new paper on word under cursor") 44 "vimwiki: new paper on word under cursor")
46 45
47-- link paper 46-- link paper
48map("n", "<leader>lp", "gewi[[/papers/<ESC>Ea]]<ESC>", "vimwiki link wrap word under cursor") 47map("n", "<leader>lp", "gewi[[/papers/<ESC>Ea]]<ESC>", "vimwiki: link wrap word under cursor")
49 48
50-- call CreateReference on word below cursor 49-- call CreateReference on word below cursor
51map("n", "<leader>nr", '<cmd>call CreateReference(expand("<cword>"))<CR>', "vimwiki new reference word under cursor") 50map("n", "<leader>nr", '<cmd>call CreateReference(expand("<cword>"))<CR>', "vimwiki: new reference word under cursor")
52 51
53-- create a new note 52-- create a new note
54map("n", "<leader>nn", "<cmd>call CreateNote()<CR>", "vimwiki new note for slipbox") 53map("n", "<leader>nn", "<cmd>call CreateNote()<CR>", "vimwiki: new note for slipbox")
55 54
56-- :%% to get current file path 55-- :%% to get current file path
57map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", "get current file path", { expr = true, silent = false }) 56map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", "get current file path", { expr = true, silent = false })
@@ -67,6 +66,10 @@ map('v', 'Y', 'myY`y')
67-- ` is more useful than ' 66-- ` is more useful than '
68map('n', "'", '`') 67map('n', "'", '`')
69 68
69-- keep cursor in the middle while doing search
70map("n", "n", "nzzzv")
71map("n", "N", "Nzzzv")
72
70-- switch between light and dark modes 73-- switch between light and dark modes
71map("n", "<leader>ut", function() 74map("n", "<leader>ut", function()
72 if vim.o.background == "dark" then 75 if vim.o.background == "dark" then
diff --git a/.config/nvim/lua/core/options.lua b/.config/nvim/lua/core/options.lua
index 3299e83..1a45b8f 100644
--- a/.config/nvim/lua/core/options.lua
+++ b/.config/nvim/lua/core/options.lua
@@ -1,75 +1,74 @@
1local opts = { 1local opts = {
2 -- this might not be needed anymore 2 -- this might not be needed anymore
3 termguicolors = true, 3 termguicolors = true,
4 4
5 -- copy indent on a new line 5 -- copy indent on a new line
6 autoindent = true, 6 autoindent = true,
7 7
8 -- :h tabstop, 2. point 8 -- :h tabstop, 2. point
9 -- use appropriate number of spaces to insert a <Tab> 9 -- use appropriate number of spaces to insert a <Tab>
10 expandtab = true, 10 expandtab = true,
11 shiftwidth = 4, 11 shiftwidth = 4,
12 softtabstop = 4, 12 softtabstop = 4,
13 tabstop = 8, 13 tabstop = 8,
14 14
15 -- use english for spellchecking 15 -- use english for spellchecking
16 spelllang = "en_gb", 16 spelllang = "en_gb",
17 17
18 -- tab completion, zsh style 18 -- tab completion, zsh style
19 wildmode = "longest:full,full", 19 wildmode = "longest:full,full",
20 20
21 -- put one space for join (not two) 21 -- put one space for join (not two)
22 joinspaces = false, 22 joinspaces = false,
23 23
24 -- keep n lines above/below cursor while scrolling 24 -- keep n lines above/below cursor while scrolling
25 scrolloff = 4, 25 scrolloff = 4,
26 26
27 -- line numbers 27 -- line numbers
28 number = true, 28 number = true,
29 29
30 -- manual folding 30 -- manual folding
31 foldmethod = "marker", 31 foldcolumn = "0",
32 foldlevel = 99,
33 foldlevelstart = 99,
34 foldenable = true,
32 35
33 -- set the terminal title 36 -- set the terminal title
34 title = true, 37 title = true,
35 38
36 -- wrap using 'breakat' character 39 -- wrap using 'breakat' character
37 linebreak = true, 40 linebreak = true,
38 41
39 -- new split panes will split to below and right 42 -- new split panes will split to below and right
40 splitbelow = true, 43 splitbelow = true,
41 splitright = true, 44 splitright = true,
42 45
43 -- use relative line numbers 46 -- use relative line numbers
44 relativenumber = true, 47 relativenumber = true,
45 48
46 -- we are already using a cursorline, don't clobber linter messages 49 -- we are already using a cursorline, don't clobber linter messages
47 showmode = false, 50 showmode = false,
48 51
49 -- jump to the matching bracket briefly 52 -- jump to the matching bracket briefly
50 showmatch = true, 53 showmatch = true,
51 54
52 -- persistent undo 55 -- persistent undo
53 undofile = true, 56 undofile = true,
54 57
55 -- lower case searches ignore case, upper case searches do not 58 -- lower case searches ignore case, upper case searches do not
56 ignorecase = true, 59 ignorecase = true,
57 smartcase = true, 60 smartcase = true,
58 61
59 -- https://stackoverflow.com/a/3445040/ 62 -- https://stackoverflow.com/a/3445040/
60 -- switch case labels 63 -- switch case labels
61 cinoptions = "l1", 64 cinoptions = "l1",
62 65
63} 66}
64 67
65for opt, val in pairs(opts) do 68for opt, val in pairs(opts) do
66 vim.o[opt] = val 69 vim.o[opt] = val
67end 70end
68 71
69-- set other options
70-- local colorscheme = require("helpers.colorscheme")
71-- vim.cmd.colorscheme(colorscheme)
72
73-- interact with system clipboard 72-- interact with system clipboard
74vim.opt.clipboard:append('unnamedplus') 73vim.opt.clipboard:append('unnamedplus')
75 74
@@ -90,7 +89,7 @@ vim.opt.diffopt = {
90 89
91-- menu: use a popup menu to show the possible completions 90-- menu: use a popup menu to show the possible completions
92-- preview: show extra information 91-- preview: show extra information
93vim.opt.completeopt = {"menu", "menuone", "noselect"} 92vim.opt.completeopt = { "menu", "menuone", "noselect" }
94 93
95if vim.fn.executable("rg") then 94if vim.fn.executable("rg") then
96 vim.o.grepprg = "rg --vimgrep --no-heading --smart-case" 95 vim.o.grepprg = "rg --vimgrep --no-heading --smart-case"
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 @@
1local function lualine_spell()
2 if vim.wo.spell then
3 return "spell"
4 else
5 return
6 end
7end
8
9local 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.
20local encoding = function()
21 local ret, _ = vim.bo.fenc:gsub("^utf%-8$", "")
22 return ret
23end
24
25-- fileformat: don't display if &ff is unix.
26local fileformat = function()
27 local ret, _ = vim.bo.fileformat:gsub("^unix$", "")
28 return ret
29end
30
1return { 31return {
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 @@
1return {
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 @@
1return {
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