V = vim -------------------------- ---- Config Section ----- --- 1 --- Options -------- -------------------------- O = V.opt O.number=true O.relativenumber=true O.tabstop=2 O.shiftwidth=2 O.expandtab=true O.preserveindent=true O.termguicolors=true O.clipboard='unnamedplus' V.cmd("colorscheme habamax") -------------------------- ---- Config Section ----- --- 2 --- Leader --------- -------------------------- V.keymap.set('n', " ", "", {silent = true, remap = false}) V.g.mapleader = " " -------------------------- ---- Config Section ----- --- 3 --- Packer conf ---- -------------------------- local fresh_install_packer = function() local packerpath = V.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if not V.loop.fs_stat(packerpath) then V.fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim.git", packerpath, }) V.cmd [[packadd packer.nvim]] return true end return false end local fresh_install = fresh_install_packer(); V.cmd([[ augroup packer_user_config autocmd! autocmd BufWritePost init.lua source | PackerCompile augroup end ]]) -------------------------- ---- Config Section ----- --- 4 --- Plugins -------- -------------------------- local packer = require('packer') packer.startup({function(u) u 'wbthomason/packer.nvim' -- LSP + Autocomplete u 'neovim/nvim-lspconfig' u 'williamboman/mason.nvim' u 'williamboman/mason-lspconfig.nvim' u 'hrsh7th/nvim-cmp' u 'hrsh7th/cmp-nvim-lsp' u 'hrsh7th/cmp-buffer' u 'hrsh7th/cmp-path' u 'L3MON4D3/LuaSnip' u 'Sirver/ultisnips' u 'honza/vim-snippets' u { 'VonHeikemen/lsp-zero.nvim', branch = 'v2.x' } -- Markdown u 'godlygeek/tabular' u 'elzr/vim-json' u 'preservim/vim-markdown' u 'vim-pandoc/vim-pandoc-syntax' u 'itchyny/calendar.vim' -- File tree, telescope u 'nvim-lua/plenary.nvim' u 'nvim-tree/nvim-web-devicons' u 'MunifTanjim/nui.nvim' u { 'nvim-neo-tree/neo-tree.nvim', branch = 'v3.x' } u { 'nvim-telescope/telescope.nvim', branch = '0.1.x' } -- Others u 'nvim-lualine/lualine.nvim' u 'folke/which-key.nvim' if fresh_install then packer.sync() end end, config = { max_jobs = 50, git = { cmd = 'git', subcommands = { update = 'pull --ff-only --progress --rebase=false --force', install = 'clone --depth %i --no-single-branch --progress', fetch = 'fetch --depth 999999 --progress --force', checkout = 'checkout %s --', update_branch = 'merge --ff-only @{u}', current_branch = 'branch --show-current', diff = 'log --color=never --pretty=format:FMT --no-show-signature HEAD@{1}...HEAD', diff_fmt = '%%h %%s (%%cr)', get_rev = 'rev-parse --short HEAD', get_msg = 'log --color=never --pretty=format:FMT --no-show-signature HEAD -n 1', submodules = 'submodule update --init --recursive --progress' }, depth = 1, clone_timeout = 5, -- in seconds default_url_format = 'https://github.com/%s' }, }}) -------------------------- ---- Config Section ----- --- 5 --- Plugins conf---- -------------------------- local telescope = require('telescope') telescope.setup(); local lsp = require('lsp-zero').preset({}) lsp.on_attach(function(client, bufnr) lsp.default_keymaps({buffer = bufnr}) end) lsp.ensure_installed({ 'lua_ls', 'tsserver', 'eslint', 'rust_analyzer' }) lsp.setup(); local cmp = require('cmp') cmp.setup { 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.Insert, select = true }), }, sources = { {name = 'buffer'}, {name = 'nvim_lsp'}, {name = 'path'} }, completion = { completeopt = 'menu,menuone,noinsert' } } local lualine = require('lualine') lualine.setup({ options = { theme = 'nord' } }); local whichkey = require('which-key') whichkey.setup() -- vim-markdown V.cmd('let g:vim_markdown_folding_disabled = 1') V.cmd('let g:vim_markdown_conceal = 0') V.cmd('let g:tex_conceal = ""') V.cmd('let g:vim_markdown_math = 1') V.cmd('let g:vim_markdown_frontmatter = 1') V.cmd('let g:vim_markdown_toml_frontmatter = 1') V.cmd('let g:vim_markdown_json_frontmatter = 1') V.cmd([[ augroup pandoc_syntax au! BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc augroup END ]]) V.cmd([[ augroup pandoc_syntax au! BufNewFile,BufFilePre,BufRead *.markdown set filetype=markdown.pandoc augroup END ]]) -------------------------- ---- Config Section ----- --- x --- Keybindings ---- -------------------------- local keymap = V.api.nvim_set_keymap local opts = { noremap = true, silent = true } keymap('n', 'w', ':w', opts) keymap('n', 'q', ':q', opts) keymap('n', 'Q', ':qa!', opts) -- Neotree keymap('n', 'e', ':Neotree toggle ', opts) -- Telescope keymap('n', 'fb', ':Telescope buffers', opts) keymap('n', 'fo', ':Telescope find_files', opts) keymap('n', 'fg', ':Telescope live_grep', opts) keymap('n', 'fh', ':Telescope help_tags', opts) keymap('n', 'fr', ':Telescope oldfiles', opts) -- Navidate windows keymap("n", "", "h", opts) keymap("n", "", "j", opts) keymap("n", "", "k", opts) keymap("n", "", "l", opts) -- Navigate buffers keymap("n", "", ":bnext", opts) keymap("n", "", ":bprevious", opts) -- Stay in indent mode keymap("v", "<", "", ">gv", opts) keymap("v", "p", '"_dP', opts) -- Move text up and down keymap("x", "J", ":move '>+1gv-gv", opts) keymap("x", "K", ":move '<-2gv-gv", opts) keymap("x", "", ":move '>+1gv-gv", opts) keymap("x", "", ":move '<-2gv-gv", opts) -- Notes keymap('n', 'tf', ':TableFormat', opts) keymap('n', 'tc', ':Toc', opts) keymap('n', 'di', ":pu='{'..strftime('%c')..'}'", opts) keymap('n', 'cs', ":Calendar -view=year -height=12 -split=vertical -position=topright", opts) keymap('n', 'o', 'oi', opts) keymap('n', 'fy', ':let @+=@%', opts) keymap('n', 'gn', 'yi[:e *', opts) keymap('n', 'gm', ':e main.md', opts) -- Misc keymap('n', '', ':red', opts) keymap('n', ';', ':nohl', opts) keymap('n', 'ns', '/Config Section', opts)