-- install packer if not already there local is_bootstrap = false local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim' if vim.fn.empty(vim.fn.glob(install_path)) > 0 then is_bootstrap = true vim.fn.system{'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path } vim.cmd [[packadd packer.nvim]] end vim -- Install Plugins require('packer').startup(function(use) use 'wbthomason/packer.nvim' use 'neovim/nvim-lspconfig' use 'nvim-treesitter/nvim-treesitter' use 'folke/neodev.nvim' use { "catppuccin/nvim", as = "catppuccin" } use { 'hrsh7th/nvim-cmp', requires = { 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', 'hrsh7th/cmp-nvim-lua', 'onsails/lspkind.nvim', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' } } use { 'j-morano/buffer_manager.nvim', requires = { 'nvim-lua/plenary.nvim'} } if is_bootstrap then require('packer').sync() end end) -- Don't run additional config if installing packer if is_bootstrap then print '==================================' print ' Plugins are being installed' print ' Wait until Packer completes,' print ' then restart nvim' print '==================================' return end -- load plugins local bufferManager = require('buffer_manager.ui') -- colorscheme require("catppuccin").setup({ flavour = "frappe", transparent_background = true, }) vim.cmd.colorscheme 'catppuccin' -- Some basic settings vim.wo.number = true vim.wo.relativenumber = true vim.o.pumheight = 20 -- Netrw vim.g.netrw_banner = 0 vim.g.netrw_liststyle = 3 -- leader vim.g.mapleader = ' ' -- keybinds vim.keymap.set('n', 'bs', bufferManager.toggle_quick_menu, {}) vim.keymap.set('n', 'ps', require('packer').sync, {}) -- Additional keybinds if lsp running local on_attach = function(client, bufnr) local bufopts = { noremap=true, silent=true, buffer=bufnr } vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) end local lsp_flags = { } local capabilities = vim.lsp.protocol.make_client_capabilities() -- capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) require("neodev").setup({ -- add any options here, or leave empty to use the default settings }) -- lsp configs require('lspconfig')['tsserver'].setup{ on_attach = on_attach, flags = lsp_flags } require('lspconfig')['lua_ls'].setup{ on_attach = on_attach, flags = lsp_flags, capabilities = capabilities, settings = { Lua = { completion = { callSnippet = "Replace" } } } } require('lspconfig')['gopls'].setup{ on_attach = on_attach, flags = lsp_flags } require('lspconfig')['emmet_ls'].setup{ on_attach = on_attach, flags = lsp_flags, capabilities = capabilities } require'lspconfig'.cssls.setup{ on_attach = on_attach, flags = lsp_flags, capabilities = capabilities } require('lspconfig')['docker_compose_language_service'].setup{ on_attach = on_attach, flags = lsp_flags, capabilities = capabilities } -- TreeSitter Config require('nvim-treesitter.configs').setup{ ensure_installed = {'go', 'toml', 'json', 'yaml', 'vim', 'typescript', 'help', 'lua', 'javascript', 'python'}, highlight = { enable = true } } -- autocompletion local cmp = require 'cmp' local lspkind = require 'lspkind' local luasnip = require 'luasnip' luasnip.config.setup {} cmp.setup { formatting = { format = lspkind.cmp_format() }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete {}, [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { 'i', 's' }), }, sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, }, }