From cae577e428d68cd3547a3ee52462a8b822358d40 Mon Sep 17 00:00:00 2001 From: Adam <56338480+adastx@users.noreply.github.com> Date: Thu, 7 Oct 2021 00:35:29 +0200 Subject: nvim setup snippets, nvim-tree, lualine(tabline) --- .config/nvim/lua/binds.lua | 4 +++- .config/nvim/lua/opts.lua | 55 +++++++++++++++++++++++++++++++++++++++----- .config/nvim/lua/plugins.lua | 22 +++++++++++++----- 3 files changed, 68 insertions(+), 13 deletions(-) diff --git a/.config/nvim/lua/binds.lua b/.config/nvim/lua/binds.lua index aebde65..3f9c6a6 100644 --- a/.config/nvim/lua/binds.lua +++ b/.config/nvim/lua/binds.lua @@ -13,7 +13,9 @@ map('n', 'h', ':wincmd h', opts) map('n', 'j', ':wincmd j', opts) map('n', 'k', ':wincmd k', opts) map('n', 'l', ':wincmd l', opts) -map('n', 'pv', ':30Lex', opts) -- open simple file explorer + +map('n', '', ':NvimTreeToggle', opts) +map('n', 'n', ':NvimTreeFindFile', opts) map('i', 'kj', '', opts) map('i', ',', ',u', opts) diff --git a/.config/nvim/lua/opts.lua b/.config/nvim/lua/opts.lua index 259f460..126d6c4 100644 --- a/.config/nvim/lua/opts.lua +++ b/.config/nvim/lua/opts.lua @@ -1,19 +1,60 @@ +-- SNIPPETS +local nvim_lsp = require('lspconfig') +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + +local servers = { 'omnisharp', 'html', 'sumneko_lua', 'bashls', 'tsserver', 'cssls' } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + capabilities = capabilities, + } +end + +vim.o.completeopt = 'menuone,noselect' +local luasnip = require 'luasnip' + -- CMP local cmp = require 'cmp' - cmp.setup { + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, mapping = { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.complete(), [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ + [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, - }) + }, + [''] = function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') + elseif luasnip.expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-expand-or-jump', true, true, true), '') + else + fallback() + end + end, + [''] = function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') + elseif luasnip.jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-jump-prev', true, true, true), '') + else + fallback() + end + end, }, sources = { { name = 'nvim_lsp' }, - } + { name = 'luasnip' }, + }, } -- C# @@ -69,4 +110,6 @@ require'nvim-treesitter.configs'.setup { }, } +-- Misc require('kommentary.config').use_extended_mappings() +vim.o.tabline = '%!v:lua.require\'luatab\'.tabline()' diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 87e57ce..53ce20c 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -1,20 +1,22 @@ -return require('packer').startup(function() +local use = require('packer').use +require('packer').startup(function() use 'wbthomason/packer.nvim' use 'gruvbox-community/gruvbox' use 'tpope/vim-fugitive' + use 'tpope/vim-surround' use 'ThePrimeagen/vim-be-good' - use 'neovim/nvim-lspconfig' use 'hrsh7th/nvim-cmp' use 'hrsh7th/cmp-nvim-lsp' use 'hrsh7th/cmp-buffer' use 'hrsh7th/cmp-path' - + use 'saadparwaiz1/cmp_luasnip' + use 'L3MON4D3/LuaSnip' use 'kyazdani42/nvim-web-devicons' use 'norcalli/nvim-colorizer.lua' use 'b3nj5m1n/kommentary' - use { + use { 'nvim-telescope/telescope.nvim', requires = { {'nvim-lua/popup.nvim'}, @@ -34,13 +36,21 @@ return require('packer').startup(function() end } + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate' + } + + use { 'alvarosevilla95/luatab.nvim', requires='kyazdani42/nvim-web-devicons' } + use { 'hoob3rt/lualine.nvim', requires = {'kyazdani42/nvim-web-devicons', opt = true} } use { - 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate' + 'kyazdani42/nvim-tree.lua', + requires = 'kyazdani42/nvim-web-devicons', + config = function() require'nvim-tree'.setup {} end } end) -- cgit v1.2.3-70-g09d2