From 1b011fe67a12fa59c719eacb1c948d6b6c18f56a Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Thu, 21 Mar 2024 17:29:10 -0500 Subject: [PATCH] new: Add back the fzf and cmp plugins to all machines --- laptop/plugins.lua | 2 +- server/keymaps.lua | 4 +++ server/plugin/cmp.lua | 72 +++++++++++++++++++++++++++++++++++++ server/plugin/lspconfig.lua | 13 +++++++ server/plugins.lua | 9 +++++ vps/keymaps.lua | 3 ++ vps/plugin/cmp.lua | 72 +++++++++++++++++++++++++++++++++++++ vps/plugin/lspconfig.lua | 13 +++++++ vps/plugins.lua | 9 +++++ 9 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 server/plugin/cmp.lua create mode 100644 server/plugin/lspconfig.lua create mode 100644 vps/plugin/cmp.lua create mode 100644 vps/plugin/lspconfig.lua diff --git a/laptop/plugins.lua b/laptop/plugins.lua index e8b1e26..d05c620 100644 --- a/laptop/plugins.lua +++ b/laptop/plugins.lua @@ -44,7 +44,7 @@ bootstrap_paq { "hrsh7th/cmp-omni", -- For LaTeX completion "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", - "SirVer/UltiSnips", -- For snippets + "SirVer/ultisnips", -- For snippets -- Support programming terms { "psliwka/vim-dirtytalk", build = ':let &rtp = &rtp | DirtytalkUpdate' }, -- vim-moonfly theme diff --git a/server/keymaps.lua b/server/keymaps.lua index 4081b9c..448bfec 100644 --- a/server/keymaps.lua +++ b/server/keymaps.lua @@ -17,6 +17,10 @@ vim.keymap.set('n', 'O', "Oj", { remap = false }) -- Use ,u for redo vim.keymap.set('n', 'u', "", { remap = false }) + +-- Find files using fzf by ,f +vim.keymap.set('n', 'f', ":Files", { remap = false }) + -- Move around buffers using ,j and ,k vim.keymap.set('n', 'k', ":bnext", { remap = false }) vim.keymap.set('n', 'j', ":bprevious", { remap = false }) diff --git a/server/plugin/cmp.lua b/server/plugin/cmp.lua new file mode 100644 index 0000000..7dc2ea7 --- /dev/null +++ b/server/plugin/cmp.lua @@ -0,0 +1,72 @@ +local cmp = require('cmp') +local cmp_autopairs = require('nvim-autopairs.completion.cmp') + +cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + end, + }, + window = { + completion = cmp.config.window.bordered(winhighlight), + documentation = cmp.config.window.bordered(winhighlight), + }, + 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 = "omni" }, + -- { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + }, {{ name = 'buffer' }} + ), + experimental = { ghost_text = true }, + }) + + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, { + { name = 'buffer' }, + }) +}) + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ '/', '?' }, { +mapping = cmp.mapping.preset.cmdline(), +sources = { + { name = 'buffer' } +} +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { +mapping = cmp.mapping.preset.cmdline(), +sources = cmp.config.sources({ + { name = 'path' } +}, { + { name = 'cmdline' } +}) +}) + +-- Insert `(` after select function or method item +cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done({ + filetypes = { + tex = false + } + }) +) diff --git a/server/plugin/lspconfig.lua b/server/plugin/lspconfig.lua new file mode 100644 index 0000000..b88019a --- /dev/null +++ b/server/plugin/lspconfig.lua @@ -0,0 +1,13 @@ +local lspconfig = require('lspconfig') +-- lspconfig.pyright.setup {} +-- lspconfig.tsserver.setup {} +-- lspconfig.rust_analyzer.setup { +-- -- Server-specific settings. See `:help lspconfig-setup` +-- settings = { +-- ['rust-analyzer'] = { +-- check = { +-- command = "clippy", +-- } +-- }, +-- }, +-- } diff --git a/server/plugins.lua b/server/plugins.lua index 840bf3d..7e460c1 100644 --- a/server/plugins.lua +++ b/server/plugins.lua @@ -33,6 +33,13 @@ bootstrap_paq { "lambdalisue/suda.vim", -- Auto toggle for number mode when vim isn't focused "sitiom/nvim-numbertoggle", + -- LSP related plugins + "neovim/nvim-lspconfig", + "hrsh7th/nvim-cmp", -- For LSP completion + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", -- Support programming terms { "psliwka/vim-dirtytalk", build = ':let &rtp = &rtp | DirtytalkUpdate' }, -- vim-moonfly theme @@ -44,5 +51,7 @@ bootstrap_paq { -- Syntax highlighting for Fish scripts "khaveesh/vim-fish-syntax", "kylechui/nvim-surround", + "junegunn/fzf", + "junegunn/fzf.vim", } diff --git a/vps/keymaps.lua b/vps/keymaps.lua index 6b165f7..59150d5 100644 --- a/vps/keymaps.lua +++ b/vps/keymaps.lua @@ -16,6 +16,9 @@ vim.keymap.set('n', 'O', "Oj", { remap = false }) -- Use ,u for redo vim.keymap.set('n', 'u', "", { remap = false }) +-- Find files using fzf by ,f +vim.keymap.set('n', 'f', ":Files", { remap = false }) + -- Move around buffers using ,j and ,k vim.keymap.set('n', 'k', ":bnext", { remap = false }) vim.keymap.set('n', 'j', ":bprevious", { remap = false }) diff --git a/vps/plugin/cmp.lua b/vps/plugin/cmp.lua new file mode 100644 index 0000000..7dc2ea7 --- /dev/null +++ b/vps/plugin/cmp.lua @@ -0,0 +1,72 @@ +local cmp = require('cmp') +local cmp_autopairs = require('nvim-autopairs.completion.cmp') + +cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + end, + }, + window = { + completion = cmp.config.window.bordered(winhighlight), + documentation = cmp.config.window.bordered(winhighlight), + }, + 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 = "omni" }, + -- { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + }, {{ name = 'buffer' }} + ), + experimental = { ghost_text = true }, + }) + + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, { + { name = 'buffer' }, + }) +}) + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ '/', '?' }, { +mapping = cmp.mapping.preset.cmdline(), +sources = { + { name = 'buffer' } +} +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { +mapping = cmp.mapping.preset.cmdline(), +sources = cmp.config.sources({ + { name = 'path' } +}, { + { name = 'cmdline' } +}) +}) + +-- Insert `(` after select function or method item +cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done({ + filetypes = { + tex = false + } + }) +) diff --git a/vps/plugin/lspconfig.lua b/vps/plugin/lspconfig.lua new file mode 100644 index 0000000..b88019a --- /dev/null +++ b/vps/plugin/lspconfig.lua @@ -0,0 +1,13 @@ +local lspconfig = require('lspconfig') +-- lspconfig.pyright.setup {} +-- lspconfig.tsserver.setup {} +-- lspconfig.rust_analyzer.setup { +-- -- Server-specific settings. See `:help lspconfig-setup` +-- settings = { +-- ['rust-analyzer'] = { +-- check = { +-- command = "clippy", +-- } +-- }, +-- }, +-- } diff --git a/vps/plugins.lua b/vps/plugins.lua index 840bf3d..c42e1a6 100644 --- a/vps/plugins.lua +++ b/vps/plugins.lua @@ -33,6 +33,13 @@ bootstrap_paq { "lambdalisue/suda.vim", -- Auto toggle for number mode when vim isn't focused "sitiom/nvim-numbertoggle", + -- LSP related plugins + "neovim/nvim-lspconfig", + "hrsh7th/nvim-cmp", -- For LSP completion + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", -- Support programming terms { "psliwka/vim-dirtytalk", build = ':let &rtp = &rtp | DirtytalkUpdate' }, -- vim-moonfly theme @@ -44,5 +51,7 @@ bootstrap_paq { -- Syntax highlighting for Fish scripts "khaveesh/vim-fish-syntax", "kylechui/nvim-surround", + "junegunn/fzf", + "junegunn/fzf.vim", }