local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd') local fn = vim.fn -- to call Vim functions e.g. fn.bufnr() local g = vim.g -- a table to access global variables local opt = vim.opt -- to set options local fn = vim.fn -- Auto install packer.nvim if not exists 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' end vim.cmd [[packadd packer.nvim]] vim.cmd([[ augroup packer_user_config autocmd! autocmd BufWritePost plugins.lua source | PackerCompile augroup end ]]) local utils = require('utils') -- Install plugins require('plugins') require('keymappings') -------------------- OPTIONS ------------------------------- cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme here cmd 'syntax enable' cmd 'filetype plugin indent on' utils.opt('o', 'swapfile', false) utils.opt('o', 'backup', false) utils.opt('o', 'spelllang', 'en,de') local indent = 2 utils.opt('b', 'expandtab', true) utils.opt('b', 'shiftwidth', indent) utils.opt('b', 'smartindent', true) utils.opt('b', 'tabstop', indent) utils.opt('o', 'hidden', true) utils.opt('o', 'ignorecase', true) utils.opt('o', 'scrolloff', 4 ) utils.opt('o', 'shiftround', true) utils.opt('o', 'relativenumber', true) utils.opt('o', 'smartcase', true) utils.opt('o', 'splitbelow', true) utils.opt('o', 'splitright', true) utils.opt('o', 'wildmode', 'list:longest') utils.opt('w', 'number', true) utils.opt('w', 'relativenumber', true) utils.opt('o', 'clipboard', 'unnamed,unnamedplus') utils.opt('o', 'mouse', 'a') utils.opt('o', 'wrap', false) utils.opt('o', 'termguicolors', true) utils.opt('o', 'splitbelow', true) utils.opt('o', 'splitright', true) utils.opt('o', 'list', true) -- Highlight on yank vim.cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' -------------------- MAPPINGS ------------------------------ -- to navigate the completion menu utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) -------------------- TREE-SITTER --------------------------- local ts = require 'nvim-treesitter.configs' ts.setup {ensure_installed = 'maintained', highlight = {enable = true}} -------------------- FZF ----------------------------------- --utils.map('n', '', ':FZF') -------------------- TELESCOPE ----------------------------- utils.map('n', 'f', 'Telescope find_files') utils.map('n', '', 'Telescope find_files') utils.map('n', 'g', 'Telescope git_files') utils.map('n', 'o', 'Telescope oldfiles') utils.map('n', 'h', 'Telescope command_history') utils.map('n', '', 'Telescope commands') utils.map('n', 'fb', 'Telescope buffers') -------------------- LSP ----------------------------------- local lsp = require 'lspconfig' -- We use the default settings for ccls and pylsp: the option table can stay empty lsp.ccls.setup {} lsp.pyright.setup{} lsp.clangd.setup{} utils.map('n', ',', 'lua vim.lsp.diagnostic.goto_prev()') utils.map('n', ';', 'lua vim.lsp.diagnostic.goto_next()') utils.map('n', 'a', 'lua vim.lsp.buf.code_action()') utils.map('n', 'd', 'lua vim.lsp.buf.definition()') utils.map('n', 'f', 'lua vim.lsp.buf.formatting()') utils.map('n', 'h', 'lua vim.lsp.buf.hover()') utils.map('n', 'm', 'lua vim.lsp.buf.rename()') utils.map('n', 'r', 'lua vim.lsp.buf.references()') utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') -------------------- GITSIGNS ------------------------------ -- require('gitsigns').setup() -------------------- LIGHTBULB ----------------------------- require('nvim-lightbulb').update_lightbulb() -------------------- CMP ----------------------------------- require('cmp_plug') -- local cmp = require'cmp' -- cmp.setup({ -- snippet = { -- expand = function(args) -- vim.fn["vsnip#anonymous"](args.body) -- end, -- }, -- mapping = { -- [''] = cmp.mapping.confirm({ select = true }), -- }, -- sources = { -- { name = '...' }, -- ... -- } -- }) -- local cmp = require 'cmp' -- local types = require('cmp.types') -- cmp.setup { -- completion = { -- autocomplete = { -- types.cmp.TriggerEvent.TextChanged, -- }, -- completeopt = 'menu,menuone,noselect', -- keyword_pattern = [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]], -- keyword_length = 1, -- get_trigger_characters = function(trigger_characters) -- return trigger_characters -- end -- }, -- snippet = { -- expand = function(args) -- require('luasnip').lsp_expand(args.body) -- end, -- }, -- mapping = { -- [''] = cmp.mapping.select_prev_item(), -- [''] = cmp.mapping.select_next_item(), -- [''] = cmp.mapping.scroll_docs(-4), -- [''] = cmp.mapping.scroll_docs(4), -- [''] = cmp.mapping.complete(), -- [''] = cmp.mapping.close(), -- [''] = 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' }, -- }, -- } -------------------- NVIM-TREE ----------------------------- g.nvim_tree_auto_open = 1 -------------------- NVIM-COMMENT -------------------------- require('nvim_comment').setup() require('nvim_comment').setup({line_mapping = '', operator_mapping = ''}) utils.map('n', '', 'gcc') utils.map('v', '', 'gc')