From 88efb9734400878b76d5a41d93024c8324b79e39 Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 23 Apr 2025 09:23:46 -0500 Subject: [PATCH] add treesitter, which-key, nvim-cmp --- lazy-lock.json | 10 +++- lua/dkelly/core/keymaps.lua | 9 +--- lua/dkelly/core/options.lua | 3 +- lua/dkelly/plugins/nvim-cmp.lua | 84 +++++++++++++++++++++++++++++++ lua/dkelly/plugins/telescope.lua | 10 +++- lua/dkelly/plugins/treesitter.lua | 46 +++++++++++++++++ lua/dkelly/plugins/which-key.lua | 9 ++++ 7 files changed, 159 insertions(+), 12 deletions(-) create mode 100644 lua/dkelly/plugins/nvim-cmp.lua create mode 100644 lua/dkelly/plugins/treesitter.lua create mode 100644 lua/dkelly/plugins/which-key.lua diff --git a/lazy-lock.json b/lazy-lock.json index e655719..2034f90 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,8 +1,16 @@ { + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lspkind-nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, + "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-tree.lua": { "branch": "master", "commit": "be5b788f2dc1522c73fb7afad9092331c8aebe80" }, + "nvim-treesitter": { "branch": "master", "commit": "684eeac91ed8e297685a97ef70031d19ac1de25a" }, + "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-web-devicons": { "branch": "master", "commit": "855c97005c8eebcdd19846f2e54706bffd40ee96" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, "telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" }, - "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" } + "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lua/dkelly/core/keymaps.lua b/lua/dkelly/core/keymaps.lua index ca0902c..78da0e7 100644 --- a/lua/dkelly/core/keymaps.lua +++ b/lua/dkelly/core/keymaps.lua @@ -7,7 +7,7 @@ keymap.set("n", "nh", ":nohl", { desc = "Clear search highlights" }) keymap.set("n", "+", "", { desc = "Increment number" }) keymap.set("n", "-", "", { desc = "Decrement number" }) --- keymap.set("n", "e", "Explore", { desc = fFile Explore" }) +keymap.set("n", "=", "z=", { desc = "Spell check alternatives" }) -- window management keymap.set("n", "wv", "v", { desc = "Split window vertically" }) @@ -30,10 +30,3 @@ keymap.set("n", "rj", "resize -5", { desc = "Decrease window he keymap.set("n", "rl", "vertical resize +5", { desc = "Increase window width" }) keymap.set("n", "rh", "vertical resize -5", { desc = "Decrease window width" }) --- fuzzy find ---local builtin = require('telescope.builtin') ---vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) ---vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) ---vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) ---vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) - diff --git a/lua/dkelly/core/options.lua b/lua/dkelly/core/options.lua index b166e88..560b672 100644 --- a/lua/dkelly/core/options.lua +++ b/lua/dkelly/core/options.lua @@ -5,6 +5,7 @@ local opt = vim.opt opt.relativenumber = true opt.number = true +opt.spell = true -- tabs & indentation opt.tabstop = 2 -- 2 spaces for tabs (prettier default) @@ -30,4 +31,4 @@ opt.clipboard:append("unnamedplus") -- use system clipboard as default register -- split windows opt.splitright = true -- split vertical window to the right -opt.splitbelow = true -- split horizantal window to the bottom +opt.splitbelow = true -- split horizontal window to the bottom diff --git a/lua/dkelly/plugins/nvim-cmp.lua b/lua/dkelly/plugins/nvim-cmp.lua new file mode 100644 index 0000000..48cb8b2 --- /dev/null +++ b/lua/dkelly/plugins/nvim-cmp.lua @@ -0,0 +1,84 @@ +return { + 'hrsh7th/nvim-cmp', + dependencies = { + -- Core completion sources + 'hrsh7th/cmp-nvim-lsp', + -- 'hrsh7th/cmp-treesitter', -- Uncomment if you have a cmp-treesitter source + -- Cmdline support + 'hrsh7th/cmp-cmdline', + -- Icons + 'onsails/lspkind-nvim', + + -- Extras you can enable later: + -- 'windwp/nvim-autopairs', -- autopairs integration + -- 'lukas-reineke/cmp-under-comparator', -- fuzzy sorting + }, + config = function() + local cmp = require('cmp') + local lspkind = require('lspkind') + + cmp.setup({ + formatting = { + format = lspkind.cmp_format({ + mode = "symbol_text", -- or "symbol" for just icons, "text" for just text + maxwidth = 50, + }), + }, + + snippet = { + expand = function(args) + -- no-op, snippet engine not installed + end, + }, + + mapping = { + [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.abort(), + }, + + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + -- { name = 'treesitter' }, -- Uncomment if you actually have cmp-treesitter + }), + + -- Extras you can enable later: + -- window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + -- }, + + -- experimental = { + -- ghost_text = true, + -- }, + }) + + -- Cmdline completion for : (commands & paths) + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' }, + { name = 'cmdline' }, + }), + }) + + -- Search completion for / (buffer) + cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' }, + }, + }) + + -- Autopairs integration (uncomment when you install nvim-autopairs) + -- require('nvim-autopairs').setup{} + -- local cmp_autopairs = require('nvim-autopairs.completion.cmp') + -- cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + + -- Fuzzy sorting (uncomment when you install cmp-under-comparator) + -- table.insert(cmp.config.sorting.comparators, require('cmp-under-comparator').under) + end, +} + diff --git a/lua/dkelly/plugins/telescope.lua b/lua/dkelly/plugins/telescope.lua index 68ba479..8a1c1a5 100644 --- a/lua/dkelly/plugins/telescope.lua +++ b/lua/dkelly/plugins/telescope.lua @@ -1,11 +1,17 @@ return { 'nvim-telescope/telescope.nvim', - dependencies = { 'nvim-lua/plenary.nvim'}, + dependencies = { + 'nvim-lua/plenary.nvim', + {'nvim-telescope/telescope-fzf-native.nvim', build = 'make'}, + 'nvim-tree-/nvim-web-devicons', + }, config = function () + local telescope = require("telescope") + telescope.load_extension("fzf") local builtin = require('telescope.builtin') vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) - vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) + vim.keymap.set('n', 'fs', 'Telescope grep_string', { desc = 'Telescope string under cursor' }) end } diff --git a/lua/dkelly/plugins/treesitter.lua b/lua/dkelly/plugins/treesitter.lua new file mode 100644 index 0000000..015ce39 --- /dev/null +++ b/lua/dkelly/plugins/treesitter.lua @@ -0,0 +1,46 @@ +return { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPre", "BufNewFile" }, + build = ":TSUpdate", + dependencies = { + "windwp/nvim-ts-autotag", + }, + config = function() + local treesitter = require("nvim-treesitter.configs") + treesitter.setup({ + highlight = { enable = true }, + indent = { enable = true }, + autotag = { enable = true }, + ensure_installed = { + -- Main programming languages + "bash", "c", "cpp", "css", "go", "html", "javascript", "json", "lua", + "make", "markdown", "markdown_inline", "python", "regex", "ruby", + "rust", "toml", "tsx", "typescript", "vim", + -- Popular config and data formats + "dockerfile", "git_config", "gitignore", "gitattributes", + "graphql", "ini", "sql", "xml", "csv", "mermaid", + -- Infra/DevOps/Cloud + "terraform", "hcl", + -- Scripting/misc + "perl", "r", "powershell", "fish", + -- Documentation & web + "latex", "scss", + -- System + "cmake", "nix", + -- Other Neovim-related + "vimdoc", + "yaml", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }) + end, +} + diff --git a/lua/dkelly/plugins/which-key.lua b/lua/dkelly/plugins/which-key.lua new file mode 100644 index 0000000..c3e7c67 --- /dev/null +++ b/lua/dkelly/plugins/which-key.lua @@ -0,0 +1,9 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 500 + end, + opt = {} +}