113 lines
4.6 KiB
Lua
113 lines
4.6 KiB
Lua
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 <afile> | 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 ------------------------------
|
|
-- <Tab> to navigate the completion menu
|
|
utils.map('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true})
|
|
utils.map('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true})
|
|
-------------------- TREE-SITTER ---------------------------
|
|
local ts = require 'nvim-treesitter.configs'
|
|
ts.setup {ensure_installed = 'maintained', highlight = {enable = true}}
|
|
|
|
-------------------- FZF -----------------------------------
|
|
--utils.map('n', '<C-P>', ':FZF<CR>')
|
|
-------------------- TELESCOPE -----------------------------
|
|
utils.map('n', '<leader>f', '<cmd>Telescope find_files<cr>')
|
|
utils.map('n', '<C-p>', '<cmd>Telescope find_files<cr>')
|
|
utils.map('n', '<leader>g', '<cmd>Telescope git_files<cr>')
|
|
utils.map('n', '<leader>o', '<cmd>Telescope oldfiles<cr>')
|
|
utils.map('n', '<leader>h', '<cmd>Telescope command_history<cr>')
|
|
utils.map('n', '<C-S-p>', '<cmd>Telescope commands<cr>')
|
|
utils.map('n', '<leader>fb', '<cmd>Telescope buffers<cr>')
|
|
utils.map('n', '<C-S-o>', '<cmd>Telescope lsp_document_symbols<cr>')
|
|
-------------------- 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', '<space>,', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>')
|
|
utils.map('n', '<space>;', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>')
|
|
utils.map('n', '<space>a', '<cmd>lua vim.lsp.buf.code_action()<CR>')
|
|
utils.map('n', '<space>d', '<cmd>lua vim.lsp.buf.definition()<CR>')
|
|
utils.map('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>')
|
|
utils.map('n', '<space>h', '<cmd>lua vim.lsp.buf.hover()<CR>')
|
|
utils.map('n', '<space>m', '<cmd>lua vim.lsp.buf.rename()<CR>')
|
|
utils.map('n', '<space>r', '<cmd>lua vim.lsp.buf.references()<CR>')
|
|
utils.map('n', '<space>s', '<cmd>lua vim.lsp.buf.document_symbol()<CR>')
|
|
|
|
-------------------- GITSIGNS ------------------------------
|
|
-- require('gitsigns').setup()
|
|
-------------------- LIGHTBULB -----------------------------
|
|
require('nvim-lightbulb').update_lightbulb()
|
|
-------------------- CMP -----------------------------------
|
|
require('cmp_plug')
|
|
-------------------- NVIM-TREE -----------------------------
|
|
g.nvim_tree_auto_open = 1
|
|
-------------------- NVIM-COMMENT --------------------------
|
|
require('nvim_comment').setup()
|
|
require('nvim_comment').setup({line_mapping = '<C-#>', operator_mapping = '<C-#>'})
|
|
utils.map('n', '<A-#>', 'gcc')
|
|
utils.map('v', '<A-#>', 'gc')
|
|
-------------------- CMAKE ---------------------------------
|
|
require('telescope').load_extension('cmake')
|
|
g.cmake_build_dir = '{cwd}/build_nvim'
|