From 11c0395f8d8cb1ec5b8f84453b770f87e7332597 Mon Sep 17 00:00:00 2001 From: lightofshadow Date: Thu, 11 Dec 2025 15:28:42 +0000 Subject: [PATCH] Added autocomplete, no LSP config, yet --- init.vim | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/init.vim b/init.vim index 2972851..3ed4213 100644 --- a/init.vim +++ b/init.vim @@ -26,6 +26,19 @@ Plug 'jiangmiao/auto-pairs' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} "shortcut to comment multiple lines" Plug 'numToStr/Comment.nvim' + + +Plug 'neovim/nvim-lspconfig' +Plug 'hrsh7th/cmp-nvim-lsp' +Plug 'hrsh7th/cmp-buffer' +Plug 'hrsh7th/cmp-path' +Plug 'hrsh7th/cmp-cmdline' +Plug 'hrsh7th/nvim-cmp' + +" For vsnip users. +Plug 'hrsh7th/cmp-vsnip' +Plug 'hrsh7th/vim-vsnip' + call plug#end() let $NVIM_TUI_ENABLE_TRUE_COLOR=1 @@ -65,7 +78,7 @@ colorscheme sonokai lua << EOF require'nvim-treesitter.configs'.setup { -- Install parsers for languages you use - ensure_installed = { "c", "cpp", "python", "lua", "vim", "go", "html", "css", "javascript"}, + ensure_installed = { "c", "cpp", "python", "lua", "vim", "go", "html", "css", "javascript", "ocaml"}, -- Install all maintained parsers -- ensure_installed = "all", @@ -94,4 +107,87 @@ require'nvim-treesitter.configs'.setup { } require('Comment').setup() +EOF + + +lua <'] = 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 = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + }, { + { name = 'buffer' }, + }) + }) + + -- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below + -- Set configuration for specific filetype. + --[[ cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, + }, { + { name = 'buffer' }, + }) + }) + require("cmp_git").setup() ]]-- + + -- 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' } + }), + matching = { disallow_symbol_nonprefix_matching = false } + }) + + -- Set up lspconfig. + local capabilities = require('cmp_nvim_lsp').default_capabilities() + -- Replace with each lsp server you've enabled. + vim.lsp.config('', { + capabilities = capabilities + }) + vim.lsp.enable('') EOF \ No newline at end of file