diff options
| author | Marcelo <setanta@gmail.com> | 2025-03-03 21:05:55 -0300 |
|---|---|---|
| committer | Marcelo Lira <setanta@gmail.com> | 2025-03-07 02:15:25 -0300 |
| commit | c78361a6155dd53cd1098f7fdf33acfea20dc903 (patch) | |
| tree | e13b8065c4a1180f3b1d483676b55af4cba2ee4c /lua/config/plugins | |
Initial commit.
Diffstat (limited to 'lua/config/plugins')
| -rw-r--r-- | lua/config/plugins/aerial.lua | 19 | ||||
| -rw-r--r-- | lua/config/plugins/colorizer.lua | 14 | ||||
| -rw-r--r-- | lua/config/plugins/colorscheme.lua | 64 | ||||
| -rw-r--r-- | lua/config/plugins/comments.lua | 7 | ||||
| -rw-r--r-- | lua/config/plugins/completion.lua | 24 | ||||
| -rw-r--r-- | lua/config/plugins/git.lua | 81 | ||||
| -rw-r--r-- | lua/config/plugins/icons.lua | 36 | ||||
| -rw-r--r-- | lua/config/plugins/lastplace.lua | 17 | ||||
| -rw-r--r-- | lua/config/plugins/lsp.lua | 106 | ||||
| -rw-r--r-- | lua/config/plugins/notes.lua | 35 | ||||
| -rw-r--r-- | lua/config/plugins/oil.lua | 9 | ||||
| -rw-r--r-- | lua/config/plugins/rest.lua | 24 | ||||
| -rw-r--r-- | lua/config/plugins/statusline.lua | 54 | ||||
| -rw-r--r-- | lua/config/plugins/telescope.lua | 117 | ||||
| -rw-r--r-- | lua/config/plugins/treesitter.lua | 179 | ||||
| -rw-r--r-- | lua/config/plugins/whichkey.lua | 13 |
16 files changed, 799 insertions, 0 deletions
diff --git a/lua/config/plugins/aerial.lua b/lua/config/plugins/aerial.lua new file mode 100644 index 0000000..d3ff5f6 --- /dev/null +++ b/lua/config/plugins/aerial.lua @@ -0,0 +1,19 @@ +return { + { + "stevearc/aerial.nvim", + opts = {}, + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-tree/nvim-web-devicons" + }, + config = function() + require("aerial").setup({ + on_attach = function(bufnr) + vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr }) + vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr }) + end, + }) + vim.keymap.set("n", "<leader>ua", "<CMD>AerialToggle!<CR>") + end, + }, +} diff --git a/lua/config/plugins/colorizer.lua b/lua/config/plugins/colorizer.lua new file mode 100644 index 0000000..b3ba3c8 --- /dev/null +++ b/lua/config/plugins/colorizer.lua @@ -0,0 +1,14 @@ +return { + { + "norcalli/nvim-colorizer.lua", + config = function() + require("colorizer").setup({ + css = { css = true }, + sass = { css = true }, + javascript = { rgb_fn = true }, + "haml", + "html", + }) + end, + }, +} diff --git a/lua/config/plugins/colorscheme.lua b/lua/config/plugins/colorscheme.lua new file mode 100644 index 0000000..056e4b6 --- /dev/null +++ b/lua/config/plugins/colorscheme.lua @@ -0,0 +1,64 @@ +return { + -- NeoVim dark colorscheme inspired by the colors of the famous painting by Katsushika Hokusai. + { + "rebelot/kanagawa.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + config = function() + require("kanagawa").setup({ + compile = false, + undercurl = true, + commentStyle = { italic = true }, + functionStyle = {}, + keywordStyle = { italic = true }, + statementStyle = { bold = true }, + typeStyle = {}, + transparent = false, + dimInactive = true, + terminalColors = true, + colors = { + palette = {}, + theme = { wave = {}, lotus = {}, dragon = {}, all = {} }, + }, + theme = "dragon", + background = { + dark = "wave", + light = "lotus" + }, + overrides = function(colors) + local theme = colors.theme + local makeDiagnosticColor = function(color) + local c = require("kanagawa.lib.color") + return { fg = color, bg = c(color):blend(theme.ui.bg, 0.95):to_hex() } + end + return { + DiagnosticVirtualTextHint = makeDiagnosticColor(theme.diag.hint), + DiagnosticVirtualTextInfo = makeDiagnosticColor(theme.diag.info), + DiagnosticVirtualTextWarn = makeDiagnosticColor(theme.diag.warning), + DiagnosticVirtualTextError = makeDiagnosticColor(theme.diag.error), + + NormalFloat = { bg = "none" }, + FloatBorder = { bg = "none" }, + FloatTitle = { bg = "none" }, + + NormalDark = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m3 }, + LazyNormal = { bg = theme.ui.bg_m3, fg = theme.ui.fg_dim }, + + Pmenu = { fg = theme.ui.shade0, bg = theme.ui.bg_p1 }, -- add `blend = vim.o.pumblend` to enable transparency + PmenuSel = { fg = "NONE", bg = theme.ui.bg_p2 }, + PmenuSbar = { bg = theme.ui.bg_m1 }, + PmenuThumb = { bg = theme.ui.bg_p2 }, + + TelescopeTitle = { fg = theme.ui.special, bold = true }, + TelescopePromptNormal = { bg = theme.ui.bg_p1 }, + TelescopePromptBorder = { fg = theme.ui.bg_p1, bg = theme.ui.bg_p1 }, + TelescopeResultsNormal = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m1 }, + TelescopeResultsBorder = { fg = theme.ui.bg_m1, bg = theme.ui.bg_m1 }, + TelescopePreviewNormal = { bg = theme.ui.bg_dim }, + TelescopePreviewBorder = { bg = theme.ui.bg_dim, fg = theme.ui.bg_dim }, + } + end, + }) + vim.cmd.colorscheme("kanagawa") + end, + }, +} diff --git a/lua/config/plugins/comments.lua b/lua/config/plugins/comments.lua new file mode 100644 index 0000000..1ec45f1 --- /dev/null +++ b/lua/config/plugins/comments.lua @@ -0,0 +1,7 @@ +return { + { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = {}, + }, +} diff --git a/lua/config/plugins/completion.lua b/lua/config/plugins/completion.lua new file mode 100644 index 0000000..722891a --- /dev/null +++ b/lua/config/plugins/completion.lua @@ -0,0 +1,24 @@ +return { + { + "saghen/blink.cmp", + dependencies = "rafamadriz/friendly-snippets", + + version = "v0.10.0", + + opts = { + keymap = { preset = 'default' }, + + appearance = { + use_nvim_cmp_as_default = true, + nerd_font_variant = 'mono' + }, + + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + }, + + signature = { enabled = true }, + }, + opts_extend = { "sources.default" } + } +} diff --git a/lua/config/plugins/git.lua b/lua/config/plugins/git.lua new file mode 100644 index 0000000..5502ce7 --- /dev/null +++ b/lua/config/plugins/git.lua @@ -0,0 +1,81 @@ +return { + { + "lewis6991/gitsigns.nvim", + config = function() + local gitsigns = require("gitsigns") + + gitsigns.setup({ + signs_staged_enable = true, + signcolumn = true, + numhl = true, + linehl = false, + word_diff = false, + watch_gitdir = { + follow_files = true + }, + auto_attach = true, + attach_to_untracked = false, + current_line_blame = false, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", + delay = 1000, + ignore_whitespace = false, + virt_text_priority = 100, + use_focus = true, + }, + current_line_blame_formatter = "<author>, <author_time:%R> - <summary>", + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + border = "none", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + + on_attach = function(bufnr) + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map("n", "]c", function() + if vim.wo.diff then + vim.cmd.normal({ "]c", bang = true }) + else + gitsigns.nav_hunk("next", { target = "all" }) + end + end, { desc = "Goto next change" }) + + map("n", "[c", function() + if vim.wo.diff then + vim.cmd.normal({ "[c", bang = true }) + else + gitsigns.nav_hunk("prev", { target = "all" }) + end + end, { desc = "Goto previous change" }) + + -- Actions + map("n", "<Leader>ga", gitsigns.stage_hunk, { desc = "stages the current block of changes to git" }) + map("n", "<Leader>gu", gitsigns.undo_stage_hunk, { desc = "undo the last (git) staged change" }) + map("n", "<Leader>gp", gitsigns.preview_hunk, { desc = "show the git diff for the current change block" }) + + map("n", "<Leader>gb", gitsigns.blame, { desc = "git blame for the whole file" }) + map("n", "<Leader>gl", gitsigns.blame_line, { desc = "git blame for the current line" }) + + map("n", "<Leader>gh", gitsigns.toggle_linehl, { desc = "toggle git diff highlight by line" }) + map("n", "<Leader>gw", gitsigns.toggle_word_diff, { desc = "toggle git diff highlight by word" }) + + -- Text object + map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>") + end, + }) + end, + }, +} diff --git a/lua/config/plugins/icons.lua b/lua/config/plugins/icons.lua new file mode 100644 index 0000000..54a924e --- /dev/null +++ b/lua/config/plugins/icons.lua @@ -0,0 +1,36 @@ +return { + { + "nvim-tree/nvim-web-devicons", + lazy = false, + config = function() + require("nvim-web-devicons").setup({ + color_icons = true, + default = true, + strict = true, + variant = "dark", + override = { + zsh = { + icon = "", + color = "#428850", + cterm_color = "65", + name = "Zsh" + }, + }, + override_by_filename = { + [".gitignore"] = { + icon = "", + color = "#f1502f", + name = "Gitignore" + }, + }, + override_by_extension = { + ["log"] = { + icon = "", + color = "#81e043", + name = "Log" + }, + }, + }) + end, + }, +} diff --git a/lua/config/plugins/lastplace.lua b/lua/config/plugins/lastplace.lua new file mode 100644 index 0000000..f409397 --- /dev/null +++ b/lua/config/plugins/lastplace.lua @@ -0,0 +1,17 @@ +return { + -- Intelligently reopen files at your last edit position in Vim. + { + "ethanholz/nvim-lastplace", + config = function() + require("nvim-lastplace").setup({ + lastplace_ignore_buftype = { "quickfix", "nofile", "help" }, + lastplace_ignore_filetype = { "gitcommit", "gitrebase" }, + lastplace_open_folds = true + }) + end + }, + + -- vim-fetch enables Vim to process line and column jump specifications + -- in file paths as found in stack traces and similar output. + { "wsdjeg/vim-fetch" }, +} diff --git a/lua/config/plugins/lsp.lua b/lua/config/plugins/lsp.lua new file mode 100644 index 0000000..16e785d --- /dev/null +++ b/lua/config/plugins/lsp.lua @@ -0,0 +1,106 @@ +return { + { + "neovim/nvim-lspconfig", + dependencies = { + "saghen/blink.cmp", + }, + opts = { + servers = { + clangd = { + cmd = { + "clangd", + "--header-insertion=iwyu", + "--background-index", + "--clang-tidy", + "--log=verbose", + }, + filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" }, + single_file_support = true, + }, + cssls = {}, + html = {}, + jsonls = {}, + lua_ls = { + settings = { + Lua = { + runtime = { + version = "LuaJIT", + }, + diagnostics = { + globals = { + "vim", + "require", + }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { + enable = false, + }, + }, + }, + }, + marksman = {}, + solargraph = { + cmd = { + vim.fn.expand('~/.local/share/nvim/mason/bin/solargraph'), + 'stdio', + }, + }, + ts_ls = {}, + }, + }, + + config = function(_, opts) + local lspconfig = require("lspconfig") + local blink = require("blink.cmp") + + for server, config in pairs(opts.servers) do + config.capabilities = blink.get_lsp_capabilities() + lspconfig[server].setup(config) + end + + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if not client then return end + + vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Jumps to definition", buffer = args.buf }) + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Jumps to declaration", buffer = args.buf }) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "Lists all implementations", buffer = args.buf }) + + vim.keymap.set("n", "<Leader>cf", function() vim.lsp.buf.format({ async = true, buffer = args.buf }) end, + { desc = "Formats a buffer", buffer = args.buf }) + vim.keymap.set("v", "<C-f>", function() vim.lsp.buf.format({ async = true, buffer = args.buf }) end, + { desc = "Formats a buffer", buffer = args.buf }) + + -- Disabled, kept temporarily here just for reference + if false and vim.bo.filetype == "lua" then + if client.supports_method("textDocument/formatting") then + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = args.buf, + callback = function() + vim.lsp.buf.format({ bufnr = args.buf, id = client.id }) + end, + }) + end + end + end + }) + + vim.diagnostic.config({ + underline = true, + virtual_text = { prefix = " ●", }, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = "", + [vim.diagnostic.severity.WARN] = "", + [vim.diagnostic.severity.INFO] = "", + [vim.diagnostic.severity.HINT] = "", + }, + }, + }) + end, + }, +} diff --git a/lua/config/plugins/notes.lua b/lua/config/plugins/notes.lua new file mode 100644 index 0000000..c374e94 --- /dev/null +++ b/lua/config/plugins/notes.lua @@ -0,0 +1,35 @@ +return { + { + "zk-org/zk-nvim", + config = function() + require("zk").setup({ + picker = "telescope", + lsp = { + config = { + cmd = { "zk", "lsp" }, + name = "zk", + }, + auto_attach = { + enabled = true, + filetypes = { "markdown" }, + }, + }, + }) + + local opts = { noremap = true, silent = false } + + -- Create a new note after asking for its title. + vim.api.nvim_set_keymap("n", "<leader>zn", "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>", opts) + + -- Open notes. + vim.api.nvim_set_keymap("n", "<leader>zo", "<Cmd>ZkNotes { sort = { 'modified' } }<CR>", opts) + -- Open notes associated with the selected tags. + vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>ZkTags<CR>", opts) + + -- Search for the notes matching a given query. + vim.api.nvim_set_keymap("n", "<leader>zf", "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>", opts) + -- Search for the notes matching the current visual selection. + vim.api.nvim_set_keymap("v", "<leader>zf", ":'<,'>ZkMatch<CR>", opts) + end + } +} diff --git a/lua/config/plugins/oil.lua b/lua/config/plugins/oil.lua new file mode 100644 index 0000000..9795053 --- /dev/null +++ b/lua/config/plugins/oil.lua @@ -0,0 +1,9 @@ +return { + { + "stevearc/oil.nvim", + opts = {}, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + }, +} diff --git a/lua/config/plugins/rest.lua b/lua/config/plugins/rest.lua new file mode 100644 index 0000000..e172764 --- /dev/null +++ b/lua/config/plugins/rest.lua @@ -0,0 +1,24 @@ +return { + { + "rest-nvim/rest.nvim", + dependencies = { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + table.insert(opts.ensure_installed, "http") + end, + init = function() + vim.g.rest_nvim = { + request = { + hooks = { + user_agent = "neovim", + }, + }, + cookies = { + enable = false, + }, + } + end, + }, + }, +} diff --git a/lua/config/plugins/statusline.lua b/lua/config/plugins/statusline.lua new file mode 100644 index 0000000..0ca9582 --- /dev/null +++ b/lua/config/plugins/statusline.lua @@ -0,0 +1,54 @@ +return { + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, + config = function() + require("lualine").setup { + options = { + icons_enabled = true, + ignore_focus = {}, + always_divide_middle = true, + separator = { left = "", right = "" }, + section_separators = "", + component_separators = "", + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { + { "branch", icon = "" }, + { "diff", symbols = { added = " ", modified = " ", removed = " " } }, + { "diagnostics" }, + }, + lualine_c = { '%=', { "filename", path = 1 } }, + lualine_x = {}, + lualine_y = { "fileformat", "encoding", "filetype" }, + lualine_z = { "progress", "location" }, + }, + inactive_sections = { + lualine_a = { + { function() return vim.api.nvim_win_get_number(0) end } + }, + lualine_b = {}, + lualine_c = { '%=', { "filename", path = 1 } }, + lualine_x = {}, + lualine_y = { "filetype" }, + lualine_z = { "location" }, + }, + tabline = { + lualine_a = { + { + "tabs", + show_modified_status = true, + use_mode_colors = true, + mode = 2, + }, + }, + lualine_b = { + { "aerial", }, + }, + }, + extensions = { "aerial", "lazy", "oil", "quickfix" } + } + end, + }, +} diff --git a/lua/config/plugins/telescope.lua b/lua/config/plugins/telescope.lua new file mode 100644 index 0000000..4faa22b --- /dev/null +++ b/lua/config/plugins/telescope.lua @@ -0,0 +1,117 @@ +return { + { + "nvim-telescope/telescope.nvim", + tag = "0.1.8", + dependencies = { + "nvim-lua/plenary.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + config = function() + require("telescope").load_extension("fzf") + end, + }, + }, + config = function() + local actions = require("telescope.actions") + local action_layout = require("telescope.actions.layout") + + local grep_appearance = { + layout_strategies = "vertical", + theme = "dropdown", + layout_config = { + prompt_position = "bottom", + width = 0.7, + height = 0.5, + }, + } + + local telescope = require("telescope") + telescope.setup({ + defaults = { + mappings = { + i = { + ["<C-h>"] = "which_key", + ["<C-c>"] = false, + ["<C-f>"] = actions.to_fuzzy_refine, + ["<ESC>"] = actions.close, + ["<M-p>"] = action_layout.toggle_preview, + }, + }, + }, + pickers = { + buffers = { + theme = "dropdown", + layout_config = { + prompt_position = "bottom", + }, + previewer = false, + sort_lastused = true, + sort_mru = true, + ignore_current_buffer = true, + }, + live_grep = grep_appearance, + grep_string = grep_appearance, + help_tags = { + theme = "dropdown", + layout_strategies = "vertical", + layout_config = { + width = 0.7, + }, + }, + }, + extensions = { + fzf = {}, + }, + }) + + local builtin = require("telescope.builtin") + + vim.keymap.set("n", "<Leader>b", builtin.buffers, { desc = "List buffers" }) + vim.keymap.set("n", "<Leader>B", function() + builtin.live_grep({ grep_open_files = true }) + end, { desc = "Searches open buffers contents" }) + + vim.keymap.set("n", "<Leader>f", builtin.live_grep, { desc = "Search file contents" }) + vim.keymap.set("n", "<Leader>F", builtin.grep_string, { desc = "Search for the string under the cursor" }) + + vim.keymap.set("n", "<Leader>m", function() + builtin.treesitter({ + symbols = "function", + previewer = true, + prompt_title = "Functions", + prompt_prefix = "𝑓" + }) + end, { desc = "Lists function names from treesitter queries", }) + + vim.keymap.set("n", "<Leader>o", function() + local ok, _ = pcall(builtin.git_files, { previewer = false }) + if not ok then + builtin.find_files() + end + end, { desc = "Open a file" }) + vim.keymap.set("n", "<Leader>O", builtin.find_files, { desc = "Open a file" }) + + vim.keymap.set("n", "<Leader>gf", function() + local ok, _ = pcall(builtin.git_status, { previewer = false }) + if not ok then + builtin.find_files() + end + end, { desc = "Show files marked as modified by git." }) + vim.keymap.set("n", "<Leader>gF", function() + local ok, _ = pcall(builtin.git_files, { + previewer = false, + git_command = { "git", "diff-tree", "--no-commit-id", "--name-only", "HEAD", "-r" } + }) + if not ok then + builtin.find_files() + end + end, { desc = "Show files in the present git commit." }) + + vim.keymap.set("n", "<Leader>gc", "<CMD>Telescope git_commits<CR>", { desc = "Show commits" }) + vim.keymap.set("n", "<Leader>gC", "<CMD>Telescope git_bcommits<CR>", { desc = "Show commits for the current buffer" }) + + telescope.load_extension("zk") + end, + }, +} diff --git a/lua/config/plugins/treesitter.lua b/lua/config/plugins/treesitter.lua new file mode 100644 index 0000000..654c688 --- /dev/null +++ b/lua/config/plugins/treesitter.lua @@ -0,0 +1,179 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + { + "nvim-treesitter/nvim-treesitter-context", + enabled = false, + config = function() + require("treesitter-context").setup({ + mode = "cursor", + max_lines = 5, + multiline_threshold = 5, + }) + end, + }, + }, + build = ":TSUpdate", + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "bash", + "c", + "css", + "diff", + "gitcommit", + "html", + "http", + "javascript", + "json", + "lua", + "make", + "markdown", + "markdown_inline", + "query", + "ruby", + "vim", + "vimdoc", + "xml", + "yaml", + }, + auto_install = false, + indent = { enable = true }, + + highlight = { + enable = true, + disable = function(_, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + additional_vim_regex_highlighting = false, + }, + + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + ["ai"] = "@conditional.outer", + ["ii"] = "@conditional.inner", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + ["ab"] = "@block.outer", + ["ib"] = "@loop.inner", + ["at"] = "@comment.outer", + }, + }, + + move = { + enable = true, + set_jumps = true, + goto_next_start = { + ["]p"] = "@parameter.inner", + ["]m"] = "@function.outer", + ["]]"] = "@class.outer", + ["]l"] = "@loop.outer", + ["]i"] = "@conditional.outer", + ["]b"] = "@block.outer", + ["]t"] = "@comment.outer", + }, + goto_next_end = { + ["]P"] = "@parameter.inner", + ["]M"] = "@function.outer", + ["]["] = "@class.outer", + ["]L"] = "@loop.outer", + ["]B"] = "@block.outer", + }, + goto_previous_start = { + ["[p"] = "@parameter.inner", + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + ["[l"] = "@loop.outer", + ["[i"] = "@conditional.outer", + ["[b"] = "@block.outer", + ["[t"] = "@comment.outer", + }, + goto_previous_end = { + ["[P"] = "@parameter.inner", + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", + ["[L"] = "@loop.outer", + ["[B"] = "@block.outer", + }, + }, + + swap = { + enable = true, + swap_next = { + ["<Leader>a"] = "@parameter.inner", + }, + swap_previous = { + ["<Leader>A"] = "@parameter.inner", + }, + }, + + lsp_interop = { + enable = true, + border = "single", + floating_preview_opts = {}, + peek_definition_code = { + ["<Leader>df"] = "@function.outer", + ["<Leader>dF"] = "@class.outer", + }, + }, + }, + }) + + -- Crystal parser + local parsers = require("nvim-treesitter.parsers") + local parser_config = parsers.get_parser_configs() + parser_config.crystal = { + install_info = { + url = "~/Downloads/src/tree-sitter-crystal", + files = { "src/parser.c", "src/scanner.c" }, + branch = "main", + }, + filetype = "cr", + } + + parser_config.haml = { + install_info = { + url = "https://github.com/vitallium/tree-sitter-haml", + files = { "src/parser.c", "src/scanner.c" }, + branch = "main", + }, + filetype = "haml", + } + + -- Code folding + vim.opt.foldlevel = 99 + vim.opt.foldlevelstart = 1 + vim.opt.foldnestmax = 4 + vim.opt.foldcolumn = "1" + vim.opt.foldenable = false + vim.api.nvim_create_autocmd("FileType", { + callback = function() + if parsers.has_parser() then + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.opt.foldtext = "" + else + vim.opt.foldmethod = "indent" + vim.opt.foldtext = "" + end + end, + desc = "Set foldmethod", + }) + end, + }, +} diff --git a/lua/config/plugins/whichkey.lua b/lua/config/plugins/whichkey.lua new file mode 100644 index 0000000..beff180 --- /dev/null +++ b/lua/config/plugins/whichkey.lua @@ -0,0 +1,13 @@ +return { + -- WhichKey is a lua plugin that displays a popup with possible keybindings of the command you started typing. + { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 10000 + end, + opts = { + }, + }, +} |
