local ensure_packer = function() local fn = vim.fn local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' if fn.empty(fn.glob(install_path)) > 0 then fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) vim.cmd [[packadd packer.nvim]] return true end return false end local packer_bootstrap = ensure_packer() return require('packer').startup(function(use) use 'wbthomason/packer.nvim' use { 'rose-pine/neovim', as = 'rose-pine', config = function() vim.cmd('colorscheme rose-pine') end } use { "SmiteshP/nvim-navic", requires = "neovim/nvim-lspconfig" } use { "folke/which-key.nvim", config = function() require("which-key").setup { -- your configuration comes here -- or leave it empty to use the default settings -- refer to the configuration section below } end } use { 'neovim/nvim-lspconfig', config = function() local lspconfig = require('lspconfig') local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) local cache = os.getenv("XDG_RUNTIME_DIR") or "/tmp/" local on_attach = function(client, bufnr) vim.api.nvim_exec_autocmds('User', {pattern = 'LspAttached'}) require('nvim-navic').attach(client, bufnr) end lspconfig.ccls.setup { on_attach = on_attach, capabilities = capabilities, single_file_support = true, init_options = { cache = { directory = cache .. "/ccls" } } } lspconfig.phpactor.setup { on_attach = on_attach, capabilities = capabilities } lspconfig.bashls.setup { on_attach = on_attach, capabilities = capabilities } lspconfig.rust_analyzer.setup { on_attach = on_attach, capabilities = capabilities } lspconfig.lua_ls.setup { on_attach = on_attach, capabilities = capabilities, settings = { Lua = { runtime = { version = 'LuaJIT', }, diagnostics = { globals = {'vim'}, }, workspace = { library = vim.api.nvim_get_runtime_file("", true), }, telemetry = { enable = false, } } } } end } use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', config = function() require'nvim-treesitter.configs'.setup { ensure_installed = { "c", "cpp", "php", "lua" }, sync_install = false, auto_install = true, highlight = { enable = true, additional_vim_regex_highlighting = false, } } end } use { 'hrsh7th/nvim-cmp', requires = { 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-vsnip', 'hrsh7th/vim-vsnip', 'hrsh7th/cmp-nvim-lsp-signature-help', 'hrsh7th/cmp-nvim-lsp-document-symbol', }, config = function() -- Setup nvim-cmp. local cmp = require'cmp' local has_words_before = function() local line, col = unpack(vim.api.nvim_win_get_cursor(0)) return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end local feedkey = function(key, mode) vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) end 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(), 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 = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif vim.fn["vsnip#available"](1) == 1 then feedkey("(vsnip-expand-or-jump)", "") elseif has_words_before() then cmp.complete() else fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. end end, { "i", "s" }), [''] = cmp.mapping(function() if cmp.visible() then cmp.select_prev_item() elseif vim.fn["vsnip#jumpable"](-1) == 1 then feedkey("(vsnip-jump-prev)", "") end end, { "i", "s" }), }), 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 = 'nvim_lsp_signature_help' } }, { { name = 'buffer' }, }) }) end } if packer_bootstrap then require('packer').sync() end end)