From f745054bbfbcc9aa8ae77d5f238cc2cf56930643 Mon Sep 17 00:00:00 2001 From: yannickreiss Date: Tue, 20 Feb 2024 08:02:09 +0100 Subject: [PATCH] Code completion with easycomplete --- lazy-lock.json | 38 +++++++++++++ lua/code-completion.lua | 118 ++++++++-------------------------------- lua/plugins.lua | 15 +---- 3 files changed, 61 insertions(+), 110 deletions(-) create mode 100644 lazy-lock.json diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..40ca95d --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,38 @@ +{ + "UltiSnips": { "branch": "master", "commit": "b393ba65386d47664421e1f8b246a87a6e8b218c" }, + "barbar.nvim": { "branch": "master", "commit": "71ac376acd000743146b1e08e62151b4d887bbac" }, + "bufstop": { "branch": "master", "commit": "e453ed3f03d53df9e8ba69225fbe523cf44b1b13" }, + "cyberspace.vim": { "branch": "master", "commit": "8d002ef6a449f08025d75249078ecae75a136a2d" }, + "formatter.nvim": { "branch": "master", "commit": "cb4778b8432f1ae86dae4634c0b611cb269a4c2f" }, + "fuzzy.nvim": { "branch": "master", "commit": "67a42ad2fa6d5ff41f0ef3cf69bb247410da5d7a" }, + "git-blame.nvim": { "branch": "master", "commit": "196602b570b1d754b7b8f9a9f75fa7bd88f12ef8" }, + "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, + "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "lexima.vim": { "branch": "master", "commit": "5513d686801993b40c55baa65602f79cd3cf3c77" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "fe4cce44dec93c69be17dad79b21de867dde118a" }, + "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, + "nerdtree": { "branch": "master", "commit": "bdf81a086dd271571104a11f555b79e5cdff5dc5" }, + "nerdtree-git-plugin": { "branch": "master", "commit": "e1fe727127a813095854a5b063c15e955a77eafb" }, + "nvim-dap": { "branch": "master", "commit": "fc880e82059eb21c0fa896be60146e5f17680648" }, + "nvim-doxyscan": { "branch": "master", "commit": "2c266fdb9395d6afa5d7188f8212fd7757193990" }, + "nvim-lspconfig": { "branch": "master", "commit": "1699ce10c3aaf861cfa0c1303fcd19d2ed93e7ad" }, + "nvim-sourcer": { "branch": "main", "commit": "a2f6bc737a63a208d39fcc5c211076ea5aa9f390" }, + "nvim-treesitter": { "branch": "master", "commit": "917d696592a34917a12208f579d5e72c1a904aee" }, + "nvim-ts-rainbow": { "branch": "master", "commit": "ef95c15a935f97c65a80e48e12fe72d49aacf9b9" }, + "nvim-web-devicons": { "branch": "master", "commit": "14ac5887110b06b89a96881d534230dac3ed134d" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope-ultisnips.nvim": { "branch": "main", "commit": "d1cca4b5aa809a90b7a8caddeb860329d5a8c2ff" }, + "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "tokyonight.nvim": { "branch": "main", "commit": "610179f7f12db3d08540b6cc61434db2eaecbcff" }, + "vim-airline": { "branch": "master", "commit": "d9f42cb46710e31962a9609939ddfeb0685dd779" }, + "vim-airline-themes": { "branch": "master", "commit": "a9aa25ce323b2dd04a52706f4d1b044f4feb7617" }, + "vim-devicons": { "branch": "master", "commit": "71f239af28b7214eebb60d4ea5bd040291fb7e33" }, + "vim-easycomplete": { "branch": "master", "commit": "dcad32ab5e935bf3042208803c09f5fc8b25adc5" }, + "vim-monokai-tasty": { "branch": "master", "commit": "57c67feac63158a232c43aee2f463a994029b699" }, + "vim-speeddating": { "branch": "master", "commit": "5a36fd29df63ea3f65562bd2bb837be48a5ec90b" }, + "vim-startify": { "branch": "master", "commit": "4e089dffdad46f3f5593f34362d530e8fe823dcf" }, + "vim-startuptime": { "branch": "master", "commit": "308b0088a864c4711a96e45b6734cf9294074f65" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, + "vim-visual-multi": { "branch": "master", "commit": "cff14071098de5279743b009c496303995fe4df9" } +} \ No newline at end of file diff --git a/lua/code-completion.lua b/lua/code-completion.lua index 4f5b9d2..5538070 100644 --- a/lua/code-completion.lua +++ b/lua/code-completion.lua @@ -4,103 +4,29 @@ -- preview: show more details vim.opt.completeopt = { "menu", "menuone" } --- shortmess is used to reduce verbocity --- vim.opt.shortmess = vim.opt.shortmess + { c = true } -local cmp = require("cmp") -cmp.setup({ - -- configuration - snippet = { - expand = function(args) - vim.fn["UltiSnips#Anon"](args.body) - end, - }, +vim.g.easycomplete_cursor_word_hl = 1 +vim.g.easycomplete_nerd_font = 1 - -- Add borders to the windows - -- window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), - -- }, +-- Bind reference and navigation options (using f as primary) +vim.keymap.set("n", "fr", ":EasyCompleteReference") +vim.keymap.set("n", "fd", ":EasyCompleteGotoDefinition") +vim.keymap.set("n", "fn", ":EasyCompleteRename") +vim.keymap.set("n", "fb", ":BackToOriginalBuffer") - -- mapping - mapping = cmp.mapping.preset.insert({ - -- Shift+TAB to go to the Previous Suggested item - [""] = cmp.mapping.select_prev_item(), - -- Tab to go to the next suggestion - [""] = cmp.mapping.select_next_item(), - -- CTRL+SHIFT+f to scroll backwards in description - [""] = cmp.mapping.scroll_docs(-4), - -- CTRL+F to scroll forwards in the description - [""] = cmp.mapping.scroll_docs(4), - -- CTRL+SPACE to bring up completion at current Cursor location - [""] = cmp.mapping.complete(), - -- CTRL+e to exit suggestion and close it - [""] = cmp.mapping.close(), -- TODO: Search better option - -- CR (enter or return) to CONFIRM the currently selection suggestion - -- We set the ConfirmBehavior to insert the Selected suggestion - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }), - }), +vim.g.easycomplete_pum_format = { "kind", "abbr", "menu" } +vim.cmd([[ + hi EasyFuzzyMatch guifg=lightblue +]]) +vim.g.easycomplete_directory_enable = 1 - -- installed sources for code suggestion - sources = cmp.config.sources({ - { name = "ultisnips", keyword_length = 1 }, - { name = "path" }, - { name = "nvim_lsp", keyword_length = 2 }, - { name = "nvim_lsp_signature_help" }, - { name = "nvim_lua", keyword_length = 4 }, - { name = "buffer", keyword_length = 3 }, - { name = "calc" }, - { name = "lua-latex-symbols", option = { cache = true } }, - -- { name = "spell", option = { keep_all_entries = false }, keyword_length = 2 }, - -- { name = "fuzzy_buffer", keyword_length = 2 }, -- Throwing unknown errors - }), +vim.g.easycomplete_tab_trigger = "" +vim.g.easycomplete_shift_tab_trigger = "" - -- add formatting of the different sources - formatting = { - fields = { "menu", "abbr", "kind" }, - format = function(entry, item) - local menu_icon = { - nvim_lsp = "λ", - ultisnips = "⋗", - path = "🌐", - calc = "Σ", - buffer = "📚", - lualatexsymbols = "𝕋", - spell = "📚", - fuzzy_buffer = "📄", - } - item.menu = menu_icon[entry.source.name] - return item - end, - }, -}) - --- Set configuration for specific filetype. -cmp.setup.filetype("gitcommit", { - sources = cmp.config.sources({ - { name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it. - }, { - { 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_history", keyword_length = 15 }, - }, { - { name = "cmdline" }, - }), -}) +-- Diagnostics +vim.g.easycomplete_diagnostics_next = "" +vim.g.easycomplete_diagnostics_prev = "" +vim.g.easycomplete_signature_offset = 0 +vim.g.easycomplete_diagnostics_enable = 1 +vim.g.easycomplete_signature_enable = 1 +vim.g.easycomplete_diagnostics_hover = 1 +vim.g.easycomplete_lsp_checking = 0 -- suppress warning on startup, must run LSPInstall manually diff --git a/lua/plugins.lua b/lua/plugins.lua index c61e9f3..fef9612 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -39,18 +39,6 @@ return { "mhinz/vim-startify", "folke/tokyonight.nvim", "patstockwell/vim-monokai-tasty", - "hrsh7th/nvim-cmp", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-nvim-lsp-signature-help", - "hrsh7th/cmp-path", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-calc", - "hrsh7th/cmp-cmdline", - "dmitmel/cmp-cmdline-history", - "amarakon/nvim-cmp-lua-latex-symbols", - "f3fora/cmp-spell", - { "petertriho/cmp-git", requires = "nvim-lua/plenary.nvim" }, "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "neovim/nvim-lspconfig", @@ -59,8 +47,7 @@ return { "mg979/vim-visual-multi", { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }, { "tzachar/fuzzy.nvim", requires = { "nvim-telescope/telescope-fzf-native.nvim" } }, - { "tzachar/cmp-fuzzy-buffer", requires = { "hrsh7th/nvim-cmp", "tzachar/fuzzy.nvim" } }, - "quangnguyen30192/cmp-nvim-ultisnips", "mihaifm/bufstop", "https://git.nickr.eu/yannickreiss/nvim-sourcer.git", + "jayli/vim-easycomplete", }