diff --git a/nvim/lua/config.lua b/nvim/lua/config.lua index 77e87297..0636b985 100644 --- a/nvim/lua/config.lua +++ b/nvim/lua/config.lua @@ -3,6 +3,82 @@ keymap = vim.api.nvim_set_keymap -- Enable ColorScheme vim.cmd[[colorscheme nord]] +-- nvim-treesiter configuration: -- setup with all defaults +require'nvim-treesitter.configs'.setup{ + ensure_installed = {"bash", "c", "c_sharp", "cmake", "cpp", "css", "dockerfile", "go", "html", "http", "java", "javascript", "json", "json5", "jsonc", "lua", "make", "markdown", "perl", "php", "pug", "python", "regex", "ruby", "toml", "tsx", "typescript", "vim", "vue", "wgsl", "yaml",}, + highlight = { enable = 'true' } +} + +-- To enable basic vim folding methods/expressions: +-- +-- vim.opt.foldmethod = "expr" +-- vim.opt.foldexpr = "nvim_treesitter#foldexpr()" +local lsp_installer = require("nvim-lsp-installer") + +lsp_installer.on_server_ready(function(server) + local opts = {} + + -- This setup() function will take the provided server configuration and decorate it with the necessary properties + -- before passing it onwards to lspconfig. + -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + server:setup(opts) +end) + -- Setup nvim-cmp. + local cmp = require'cmp' + + cmp.setup({ + 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 = 'buffer' }, + }) + }) + + -- 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 `/` (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' } + }) + }) + +-- Setup lspconfig. +local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) +-- Replace with each lsp server you've enabled. +local lspconfig =require'lspconfig' +-- Enable some language servers with the additional completion capabilities offered by nvim-cmp +local servers = { 'sumneko_lua', 'eslint', 'pyright', 'bashls', 'clangd', 'volar', 'zk' } +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + capabilities = capabilities, + } +end + -- Nvim_Tree configuration: -- setup with all defaults -- each of these are documented in `:help nvim-tree.OPTION_NAME` require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS diff --git a/nvim/lua/keybindings.lua b/nvim/lua/keybindings.lua index 3739f2e8..6b022a5d 100644 --- a/nvim/lua/keybindings.lua +++ b/nvim/lua/keybindings.lua @@ -10,8 +10,7 @@ keymap('n', '', ':tabprevious', {}) keymap('n', '', ':tabnext', {}) -- Use ctrl- [hl] to select the active split! -keymap('n', '', ':wincmd h', {}) -keymap('n', '', ':wincmd l', {}) +keymap('n', '', ':wincmd h', {}) keymap('n', '', ':wincmd l', {}) -- Toggle NERDCommenter with Ctrl + c vim.cmd[[:map NERDCommenterToggle]] diff --git a/nvim/lua/packages.lua b/nvim/lua/packages.lua index a4cf9860..669bbc21 100644 --- a/nvim/lua/packages.lua +++ b/nvim/lua/packages.lua @@ -1,20 +1,33 @@ --- Packages installed using 'packer', install using :PackerSync +-- packer.nvim requires nvim-packer-git package +-- paru -S nvim-packer-git --- call Plug for MarkDownPreview --- vim.cmd[[call plug#begin('~/.vim/plugged') Plug 'iamcco/markdown-preview.nvim', {'do': { -> mkdp#util#install() }}]] +-- Packages installed using 'packer', install using :PackerSync +-- Remove packages by deleting (or commenting out) use line below and running :PackerClean require('packer').startup(function() use 'wbthomason/packer.nvim' + use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'} + -- :TSInstall + -- :TSUpdate all + use 'neovim/nvim-lspconfig' + use 'williamboman/nvim-lsp-installer' + -- :LspInstallInfo (use i to install, u to upgrade, r to uninstall) + -- :LspUninstall [--sync] ... + -- NVim Completion packages + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/cmp-path' + use 'hrsh7th/cmp-cmdline' + use 'hrsh7th/nvim-cmp' + use 'kyazdani42/nvim-web-devicons' -- for file icons use 'kyazdani42/nvim-tree.lua' use {'nvim-lualine/lualine.nvim', requires = { 'kyazdani42/nvim-web-devicons', opt = true }} use 'shaunsingh/nord.nvim' use 'psliwka/vim-smoothie' -- use 'mattn/emmet-vim' - -- use 'ap/vim-css-color' -- use 'airblade/vim-gitgutter' use 'ctrlpvim/ctrlp.vim' -- fuzzy find files - -- use {'junegunn/fzf', run = ':call fzf#installo()'}--{ 'do': { -> fzf#install() } } use 'preservim/nerdcommenter' use 'Yggdroot/indentLine' use 'mg979/vim-visual-multi'-- {'branch': 'master'}