From c49b758e86b75f4a24bcb59ec797bac5defa8040 Mon Sep 17 00:00:00 2001 From: Ruslan Date: Thu, 14 Nov 2024 15:58:58 +0200 Subject: [PATCH] configure folding --- README.md | 1 + after/ftplugin/markdown.lua | 2 ++ lazy-lock.json | 21 ++++++----- lua/crentist/lazy/colors.lua | 6 +++- lua/crentist/lazy/lsp.lua | 3 +- lua/crentist/lazy/obsidian.lua | 62 ++++++++++++++++++++++++++++++++ lua/crentist/lazy/oil.lua | 3 ++ lua/crentist/lazy/treesitter.lua | 3 +- lua/crentist/lazy/ufo.lua | 43 ++++++++++++++++++++++ lua/crentist/luasnip.lua | 34 ++++++++++++++++-- lua/crentist/set.lua | 2 +- 11 files changed, 166 insertions(+), 14 deletions(-) create mode 100644 after/ftplugin/markdown.lua create mode 100644 lua/crentist/lazy/obsidian.lua create mode 100644 lua/crentist/lazy/ufo.lua diff --git a/README.md b/README.md index a3583e9..efb4e2d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # My nvim configuration This mostly copies ThePrimeagen configs with some changes because I don't use dvorak + diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua new file mode 100644 index 0000000..0466635 --- /dev/null +++ b/after/ftplugin/markdown.lua @@ -0,0 +1,2 @@ +vim.opt_local.conceallevel = 2 + diff --git a/lazy-lock.json b/lazy-lock.json index 975f3d4..af7613c 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,5 +1,5 @@ { - "LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, + "LuaSnip": { "branch": "master", "commit": "787dee55ca364cc9119787165418fe93b74c1842" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-dotenv": { "branch": "main", "commit": "4dd53aab60982f1f75848aec5e6214986263325e" }, @@ -12,29 +12,34 @@ "git-blame.nvim": { "branch": "master", "commit": "2883a7460f611c2705b23f12d58d398d5ce6ec00" }, "gruvbox.nvim": { "branch": "main", "commit": "49d9c0b150ba70efcd831ec7b3cb8ee740067045" }, "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, - "hererocks": { "branch": "master", "commit": "8bd2fcfdd65cfa7535ce39ea372a63b0bdb8e528" }, + "hererocks": { "branch": "master", "commit": "9ecd76ef01ad04710f6a51814576715f64a1be5a" }, "icon-picker.nvim": { "branch": "master", "commit": "3ee9a0ea9feeef08ae35e40c8be6a2fa2c20f2d3" }, "indent-blankline.nvim": { "branch": "master", "commit": "e7a4442e055ec953311e77791546238d1eaae507" }, - "lazy.nvim": { "branch": "main", "commit": "1159bdccd8910a0fd0914b24d6c3d186689023d9" }, + "lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" }, "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7446f47b3dfb7df801f31a6f6783c2ad119a6935" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, + "none-ls.nvim": { "branch": "main", "commit": "dcc8cd4efdcb29275681a3c95786a816330dbca6" }, "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, - "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-cmp": { "branch": "main", "commit": "29fb4854573355792df9e156cb779f0d31308796" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-lspconfig": { "branch": "master", "commit": "056f569f71e4b726323b799b9cfacc53653bceb3" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, "nvim-sops": { "branch": "main", "commit": "cb2209562d00ef8c6c88bdec836d9edb8fbb96ef" }, "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, - "nvim-treesitter": { "branch": "master", "commit": "5a2ff8b7ca5470b1011ed82ef3fdd53139ffc467" }, + "nvim-treesitter": { "branch": "master", "commit": "377039daa260b71f304c881d1b21d643c501a261" }, + "nvim-ufo": { "branch": "main", "commit": "c070ee849bfedb2ed778f60419a1eae8c8544be8" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, - "oil.nvim": { "branch": "master", "commit": "ccab9d5e09e2d0042fbbe5b6bd05e82426247067" }, + "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, + "oil.nvim": { "branch": "master", "commit": "39dbf875861449cf09e936fa80073f3413e9439c" }, "plenary": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, "search.nvim": { "branch": "main", "commit": "7b8f2315d031be73e14bc2d82386dfac15952614" }, + "statuscol.nvim": { "branch": "main", "commit": "8822f76e105549620ef9c0d96e7b95aedf14c490" }, "telescope.nvim": { "branch": "master", "commit": "df534c3042572fb958586facd02841e10186707c" }, - "trouble.nvim": { "branch": "main", "commit": "254145ffd528b98eb20be894338e2d5c93fa02c2" }, + "trouble.nvim": { "branch": "main", "commit": "2f3b537f2207ce32f4459f9d56746ee013b5e01b" }, "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" }, "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" }, "vim-gitgutter": { "branch": "main", "commit": "7b0b5098e3e57be86bb96cfbf2b8902381eef57c" }, diff --git a/lua/crentist/lazy/colors.lua b/lua/crentist/lazy/colors.lua index e6e6a02..0f6e1ba 100644 --- a/lua/crentist/lazy/colors.lua +++ b/lua/crentist/lazy/colors.lua @@ -9,12 +9,16 @@ return { } }) vim.cmd("colorscheme gruvbox") + + vim.api.nvim_set_hl(0, "FoldColumn", { bg = "#282828", fg = "#808080" }) + vim.api.nvim_set_hl(0, 'SignColumn', { link = 'FoldColumn' }) end }, { "norcalli/nvim-colorizer.lua", - config = function () + config = function() require('colorizer').setup({ '*' }) end } } + diff --git a/lua/crentist/lazy/lsp.lua b/lua/crentist/lazy/lsp.lua index d10e55d..c208b7c 100644 --- a/lua/crentist/lazy/lsp.lua +++ b/lua/crentist/lazy/lsp.lua @@ -1,6 +1,6 @@ return { 'neovim/nvim-lspconfig', - tag = "v1.0.0", + tag = 'v1.0.0', dependencies = { 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', @@ -41,6 +41,7 @@ return { 'ansiblels', 'terraformls', 'helm_ls', + 'marksman', }, handlers = { function(server_name) diff --git a/lua/crentist/lazy/obsidian.lua b/lua/crentist/lazy/obsidian.lua new file mode 100644 index 0000000..67c4a92 --- /dev/null +++ b/lua/crentist/lazy/obsidian.lua @@ -0,0 +1,62 @@ +return { + 'epwalsh/obsidian.nvim', + version = '*', -- recommended, use latest release instead of latest commit + -- lazy = true, + -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: + -- event = { + -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. + -- -- E.g. 'BufReadPre ' .. vim.fn.expand '~' .. '/my-vault/*.md' + -- -- refer to `:h file-pattern` for more examples + -- 'BufReadPre /Users/rtim/Documents/Notes/tech-work-hobby/*.md', + -- 'BufNewFile /Users/rtim/Documents/Notes/tech-work-hobby/*.md', + -- }, + dependencies = { + -- Required. + 'nvim-lua/plenary.nvim', + }, + keys = { + {'ot', 'ObsidianToday', desc = "Open today's daily note"}, + {'os', 'ObsidianQuickSwitch', desc = 'Search notes in my vault and switch to selected'}, + }, + mappings = { + -- Overrides the 'gf' mapping to work on markdown/wiki links within your vault. + ["gf"] = { + action = function() + return require("obsidian").util.gf_passthrough() + end, + opts = { noremap = false, expr = true, buffer = true }, + }, + -- Toggle check-boxes. + ["ch"] = { + action = function() + return require("obsidian").util.toggle_checkbox() + end, + opts = { buffer = true }, + }, + -- Smart action depending on context, either follow link or toggle checkbox. + [""] = { + action = function() + return require("obsidian").util.smart_action() + end, + opts = { buffer = true, expr = true }, + }, + }, + opts = { + workspaces = { + { + name = 'tech-work-hobby', + path = '/Users/rtim/Documents/Notes/tech-work-hobby/', + }, + }, + daily_notes = { + folder = 'Daily', + date_format = '%d-%b-%y (%A)', + default_tags = { 'daily' }, + template = 'Daily.md', + }, + templates = { + folder = 'Templates', + } + }, +} + diff --git a/lua/crentist/lazy/oil.lua b/lua/crentist/lazy/oil.lua index e34f45d..f1c5220 100644 --- a/lua/crentist/lazy/oil.lua +++ b/lua/crentist/lazy/oil.lua @@ -10,6 +10,9 @@ return { }, keymaps = { [''] = false, + [''] = false, + [''] = false, + [''] = false, } }) end diff --git a/lua/crentist/lazy/treesitter.lua b/lua/crentist/lazy/treesitter.lua index daa74c3..507511a 100644 --- a/lua/crentist/lazy/treesitter.lua +++ b/lua/crentist/lazy/treesitter.lua @@ -1,5 +1,5 @@ return { - "nvim-treesitter/nvim-treesitter", + 'nvim-treesitter/nvim-treesitter', build = ":TSUpdate", config = function() require("nvim-treesitter.configs").setup({ @@ -28,3 +28,4 @@ return { }) end } + diff --git a/lua/crentist/lazy/ufo.lua b/lua/crentist/lazy/ufo.lua new file mode 100644 index 0000000..9f654df --- /dev/null +++ b/lua/crentist/lazy/ufo.lua @@ -0,0 +1,43 @@ +return { + 'kevinhwang91/nvim-ufo', + event = 'BufReadPost', + dependencies = { + 'kevinhwang91/promise-async', + 'nvim-treesitter/nvim-treesitter', + { + 'luukvbaal/statuscol.nvim', + config = function() + local builtin = require('statuscol.builtin') + require('statuscol').setup({ + relculright = true, + segments = { + { text = { builtin.foldfunc }, sign = { colwidth = 2 }, click = 'v:lua.ScFa', }, + { text = { '%s' }, click = 'v:lua.ScSa', }, + { text = { builtin.lnumfunc, ' ' }, click = 'v:lua.ScLa', hl = 'FoldColumn' }, + }, + }) + end + } + }, + init = function() + vim.opt.foldenable = true + vim.opt.foldcolumn = '1' + vim.opt.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value + vim.opt.foldlevelstart = 99 + vim.opt.fillchars = 'eob: ,fold: ,foldopen:,foldsep: ,foldclose:' + vim.opt.foldtext = '' + end, + opts = { + provider_selector = function(bufnr, filetype, buftype) + return { 'treesitter', 'indent' } + end + }, + config = function() + require('ufo').setup({ + provider_selector = function(bufnr, filetype, buftype) + return { 'treesitter', 'indent' } + end + }) + end +} + diff --git a/lua/crentist/luasnip.lua b/lua/crentist/luasnip.lua index ab7ef27..975d503 100644 --- a/lua/crentist/luasnip.lua +++ b/lua/crentist/luasnip.lua @@ -11,7 +11,9 @@ vim.keymap.set({ "i", "s" }, "", function() end end, { desc = "Snippet next argument", silent = true }) --- nvim config +-------------------- +-- Snippets for LUA +-------------------- ls.add_snippets('lua', { s({ name = 'LuaSnip Snippet', trig = 'snipf' }, fmt([[ @@ -44,7 +46,9 @@ ls.add_snippets('lua', { ), }) --- Comment block +-------------------- +-- Generic snippets +-------------------- local function com_string(_, snip, to_multiply) local comment_string = vim.bo.commentstring local repeats = snip.captures[1] @@ -78,3 +82,29 @@ ls.add_snippets('all', { ), }) +-------------------- +-- Terraform +-------------------- +ls.add_snippets('terraform', { + s({ name = 'data_assume', trig = 'tf_assume' }, + fmt([[ + data "aws_iam_policy_document" "" { + statement { + actions = ["sts:AssumeRole"] + + principals { + type = "Service" + identifiers = [".amazonaws.com"] + } + } + } + ]], + { + name = i(1, 'assume'), + service = i(2, 'service') + }, + { delimiters = '<>' } + ) + ), +}) + diff --git a/lua/crentist/set.lua b/lua/crentist/set.lua index 18acbf1..d93ae3d 100644 --- a/lua/crentist/set.lua +++ b/lua/crentist/set.lua @@ -23,7 +23,7 @@ vim.opt.incsearch = true vim.opt.termguicolors = true vim.opt.scrolloff = 8 -vim.opt.signcolumn = "yes" +vim.opt.signcolumn = "yes:1" vim.opt.isfname:append("@-@") vim.opt.updatetime = 50