From a088a7565a4e746eaccbc4ce17021b440b927e86 Mon Sep 17 00:00:00 2001 From: Dan Chadwick Date: Mon, 11 Nov 2024 12:05:28 -0500 Subject: [PATCH] Update everything, improve autocomplete and snippets. --- init.lua | 30 ++++-------------- lazy-lock.json | 28 +++++++++-------- lua/dan/completion.lua | 37 ++++++++++++++++++++++ lua/dan/core.lua | 5 ++- lua/plugins/completions.lua | 50 ++++++++---------------------- lua/plugins/lsp-config.lua | 61 ++++++++++++++++++------------------- lua/plugins/strudel.lua | 1 + lua/plugins/treesitter.lua | 4 +-- 8 files changed, 107 insertions(+), 109 deletions(-) create mode 100644 lua/dan/completion.lua create mode 100644 lua/plugins/strudel.lua diff --git a/init.lua b/init.lua index 950cf38..eff10b2 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,6 @@ +-- Pull in core keybindings -- require("dan.core") + -- Lazy VIM -- local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then @@ -13,16 +15,18 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) require("lazy").setup("plugins") + +-- SET NEOVIM THEME -- vim.cmd.colorscheme('catppuccin') + +-- XDEBUG -- local dap = require('dap') require('telescope').load_extension('dap') - dap.adapters.php = { type = "executable", command = "node", args = { os.getenv("HOME") .. "/vscode-php-debug/out/phpDebug.js" } } - dap.configurations.php = { { type = "php", @@ -42,7 +46,6 @@ dap.configurations.php = { } } } - vim.keymap.set('n', '?', function() dap.continue() end) vim.keymap.set('n', 'N', function() dap.step_over() end) vim.keymap.set('n', 'n', function() dap.step_into() end) @@ -51,29 +54,8 @@ vim.keymap.set('n', 'b', function() dap.toggle_breakpoint() end) vim.keymap.set('n', 'B', function() dap.set_breakpoint() end) vim.keymap.set('n', 'dr', function() dap.repl.open() end) vim.keymap.set('n', 'dl', function() dap.run_last() end) --- vim.keymap.set({'n', 'v'}, 'dh', function() --- require('dap.ui.widgets').hover() --- end) --- vim.keymap.set({'n', 'v'}, 'dp', function() --- require('dap.ui.widgets').preview() --- end) --- vim.keymap.set('n', 'df', function() --- local widgets = require('dap.ui.widgets') --- widgets.centered_float(widgets.frames) --- end) vim.keymap.set('n', 'db', function() local widgets = require('dap.ui.widgets') widgets.centered_float(widgets.scopes) end) --- dap.listeners.after.event_initialized["dapui_config"] = function() --- dapui.open() --- end - --- dap.listeners.before.event_terminated["dapui_config"] = function() --- dapui.close() --- end - --- dap.listeners.before.event_exited["dapui_config"] = function() --- dapui.close() --- end diff --git a/lazy-lock.json b/lazy-lock.json index f7f56d0..7ae83a0 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,29 +1,31 @@ { - "LuaSnip": { "branch": "master", "commit": "787dee55ca364cc9119787165418fe93b74c1842" }, + "LuaSnip": { "branch": "master", "commit": "2737edc9e674e537dc0a97e3405658d57d2d31ed" }, "alpha-nvim": { "branch": "main", "commit": "bf3c8bb8c02ed3d9644cc5bbc48e2bdc39349cd7" }, - "catppuccin": { "branch": "main", "commit": "d9ee9a35f46f0a2bda9a15b5a763fee4095428fd" }, + "catppuccin": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, - "lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" }, + "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, "lazygit.nvim": { "branch": "main", "commit": "56760339a81cd1540d5a72fd9d93010a2677b55d" }, - "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "7446f47b3dfb7df801f31a6f6783c2ad119a6935" }, + "lspkind.nvim": { "branch": "master", "commit": "a700f1436d4a938b1a1a93c9962dc796afbaef4d" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, - "nvim-cmp": { "branch": "main", "commit": "29fb4854573355792df9e156cb779f0d31308796" }, - "nvim-dap": { "branch": "master", "commit": "7ff6936010b7222fea2caea0f67ed77f1b7c60dd" }, + "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, + "nvim-dap": { "branch": "master", "commit": "8517126e9323e346f6a99b3b594c5a940b914dcd" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, - "nvim-dap-virtual-text": { "branch": "master", "commit": "52638640ae309cacdaff785fdbb854437bd1ee5c" }, - "nvim-lspconfig": { "branch": "master", "commit": "28b205ebe73a18f401e040585106f9bafd8ff21f" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" }, + "nvim-lspconfig": { "branch": "master", "commit": "4cb925e96288a71409a86c84fd97f4434a95453e" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-treesitter": { "branch": "master", "commit": "48fc5d1dfe3dded8028826dfee7526e26212c73b" }, + "nvim-treesitter": { "branch": "master", "commit": "bb06afa3f1111780932b3c5493ad65473ce85f9d" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "telescope-dap.nvim": { "branch": "master", "commit": "8c88d9716c91eaef1cdea13cb9390d8ef447dbfe" }, + "telescope-dap.nvim": { "branch": "master", "commit": "783366bd6c1e7fa0a5c59c07db37f49c805a28df" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, "vim-commentary": { "branch": "master", "commit": "64a654ef4a20db1727938338310209b6a63f60c9" } diff --git a/lua/dan/completion.lua b/lua/dan/completion.lua new file mode 100644 index 0000000..0147330 --- /dev/null +++ b/lua/dan/completion.lua @@ -0,0 +1,37 @@ +-- vim.opt.completeopt = { "menu", "menuone", "noselect" } +-- vim.opt.shortmess:append "c" + +local lspkind = require "lspkind" +lspkind.init {} + +local cmp = require "cmp" + +cmp.setup { + sources = { + { name = "nvim_lsp" }, + { name = "cody" }, + { name = "path" }, + { name = "buffer" }, + }, + mapping = { + [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping( + cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + { "i", "c" } + ), + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + -- Enable luasnip to handle snippet expansion for nvim-cmp + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, +} diff --git a/lua/dan/core.lua b/lua/dan/core.lua index 25a6297..b611ec5 100644 --- a/lua/dan/core.lua +++ b/lua/dan/core.lua @@ -1,6 +1,9 @@ vim.g.mapleader = " " vim.keymap.set("n", "pv", vim.cmd.Ex) vim.keymap.set("n", "gg", vim.cmd.LazyGit) +vim.keymap.set("n", "nt", function() + vim.cmd("tabnew") +end) vim.cmd("set expandtab") vim.cmd("set tabstop=2") vim.cmd("set softtabstop=2") @@ -13,7 +16,7 @@ vim.cmd("set rnu") vim.cmd("set number relativenumber") vim.cmd("set nu rnu") vim.api.nvim_set_option("clipboard","unnamed") -vim.api.nvim_create_user_command("DiagnosticToggle", function() +vim.api.nvim_create_user_command("DiagnosticsToggle", function() local config = vim.diagnostic.config local vt = config().virtual_text config { diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index 1124107..d873844 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -1,44 +1,18 @@ return { - { - "hrsh7th/cmp-nvim-lsp" - }, - { - "L3MON4D3/LuaSnip", - dependencies = { - "saadparwaiz1/cmp_luasnip", - "rafamadriz/friendly-snippets" - } - }, { "hrsh7th/nvim-cmp", + lazy = false, + priority = 100, + dependencies = { + "onsails/lspkind.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "hrsh7th/cmp-buffer", + { "L3MON4D3/LuaSnip", build = "make install_jsregexp" }, + "saadparwaiz1/cmp_luasnip", + }, config = function() - local cmp = require("cmp") - require("luasnip.loaders.from_vscode").lazy_load() - cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - end, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }), - sources = cmp.config.sources({ - -- { name = 'nvim_lsp' }, - -- { name = 'vsnip' }, -- For vsnip users. - { name = 'luasnip' }, -- For luasnip users. - }, { - { name = 'buffer' }, - }) - }) + require "dan.completion" end - }, + } } diff --git a/lua/plugins/lsp-config.lua b/lua/plugins/lsp-config.lua index aaac69f..ea8bb9c 100644 --- a/lua/plugins/lsp-config.lua +++ b/lua/plugins/lsp-config.lua @@ -1,36 +1,35 @@ return { - { - "williamboman/mason.nvim", - config = function() - require("mason").setup() - end - }, - { - "williamboman/mason-lspconfig.nvim", - config = function() - require("mason-lspconfig").setup({ - ensure_installed = { "lua_ls", "phpactor", "rust_analyzer" } + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end, + }, + { + "williamboman/mason-lspconfig.nvim", + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls", "phpactor", "rust_analyzer" }, + }) + end, + }, + { + "neovim/nvim-lspconfig", + config = function() + local capabilities = require("cmp_nvim_lsp").default_capabilities() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup({ + capabilities = capabilities, }) - end - }, - { - "neovim/nvim-lspconfig", - config = function() - local capabilities = require('cmp_nvim_lsp').default_capabilities() - local lspconfig = require("lspconfig") - lspconfig.lua_ls.setup({ - capabilities = capabilities + lspconfig.phpactor.setup({ + capabilities = capabilities, }) - lspconfig.phpactor.setup({ - capabilities = capabilities + lspconfig.rust_analyzer.setup({ + capabilities = capabilities, }) - lspconfig.rust_analyzer.setup({ - capabilities = capabilities - }) - vim.keymap.set("n", 'K', vim.lsp.buf.hover, {}) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) - vim.keymap.set({ 'n' }, 'ca', vim.lsp.buf.code_action, {}) - - end - } + vim.keymap.set("n", "K", vim.lsp.buf.hover, {}) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, {}) + vim.keymap.set({ "n" }, "ca", vim.lsp.buf.code_action, {}) + end, + }, } diff --git a/lua/plugins/strudel.lua b/lua/plugins/strudel.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/plugins/strudel.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 9689540..7a1f137 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -4,10 +4,10 @@ return { config = function() local configs = require("nvim-treesitter.configs") configs.setup({ - ensure_installed = { "php", "lua", "vim", "javascript", "html", "yaml", "twig" }, + ensure_installed = { "php", "lua", "vim", "javascript", "html", "yaml", "twig", "vimdoc", "markdown", "markdown_inline" }, sync_install = false, highlight = { enable = true }, - indent = { enable = true }, + indent = { enable = true }, }) end }