-- Core vim settings vim.opt.background="dark" vim.opt.copyindent=true vim.opt.expandtab=false vim.opt.hidden=true vim.opt.ignorecase=true vim.opt.mouse="a" vim.opt.number=true vim.opt.relativenumber=true vim.opt.shiftwidth=4 vim.opt.smartcase=true vim.opt.tabstop=4 vim.opt.preserveindent=true vim.opt.softtabstop=0 vim.opt.wrap=false vim.opt.showcmd=true vim.opt.cursorline=true vim.opt.lazyredraw=true vim.opt.showmatch=true vim.opt.hlsearch=true vim.opt.backup=false vim.opt.writebackup=false vim.opt.signcolumn="yes" vim.opt.listchars="tab:→ ,extends:→,precedes:←,trail:·,eol:¬" vim.opt.list=true -- dunno about these? -- syntax enable -- on by default in neovim vim.cmd [[colorscheme gruvbox]] -- ====================================================================== -- -- nvim-cmp configuration -- -- ====================================================================== --local cmp = require'cmp' --cmp.setup({ --snippet = { --expand = function(args) --vim.fn["vsnip#anonymous"](args.body) --end, --}, --window = { ---- completion = cmp.config.window.bordered(), ---- documentation = cmp.config.window.bordered(), --}, --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 }), --}), --sources = cmp.config.sources({ --{ name = 'nvim_lspconfig' }, --{ name = 'vsnip' }, --},{ --{ name = 'buffer' } --}) --}) -- --cmp.setup.filetype('gitcommit', { --sources = cmp.config.sources({ --{ name = 'git' } --},{ --{ name = 'buffer' } --}) --}) -- --cmp.setup.cmdline({ '/', '?' }, { --mapping = cmp.mapping.preset.cmdline(), --sources = { { name = 'buffer' } } --}) -- --cmp.setup.cmdline(':', { --mapping = cmp.mapping.preset.cmdline(), --sources = cmp.config.sources({ --{ name = 'path' } --},{ --{ name = 'cmdline' } --}) --}) -- --local capabilities = require('cmp_nvim_lsp').default_capabilities() --local lspconfig = require('lspconfig') ---- Add each LSP that you have configured here ----require('lspconfig')[''].setup { ---- capabilities = capabilities ----} ----lspconfig.pyright.setup { capabilities = capabilities } --lspconfig.ansiblels.setup { capabilities = capabilities } --lspconfig.jedi_language_server.setup { capabilities = capabilities } -- ====================================================================== -- -- automatic commands -- -- ====================================================================== local api = vim.api -- Highlights bad whitespace --api.nvim_create_autocmd("ColorScheme", { command = "highlight ExtraWhitespace ctermbg=red guibg=red" }) --api.nvim_create_autocmd("BufWinEnter", { command = "match ExtraWhitespace /\s\+$/" }) --api.nvim_create_autocmd("InsertEnter", { command = "match ExtraWhitespace /\s\+\%#\@ \be -- imap \be vim.keymap.set(all, "", "\\be") -- map :NERDTreeToggle vim.keymap.set(all, "", ":NERDTreeToggle") -- Which file list to pop up -- silent !git rev-parse --is-inside-work-tree -- if v:shell_error == 0 -- map :GFiles --cached --others --exclude-standard -- map :GFiles? --else -- map :Files --endif if api.nvim_command_output("!git rev-parse --is-inside-work-tree") == true then vim.keymap.set(all, "", ":GFiles --cached --others --exclude-standard") vim.keymap.set(all, "", ":GFiles?") else vim.keymap.set(all, "", ":Files") end -- map :Files vim.keymap.set(all, "", ":Files") -- Allows navigating splits -- map j -- map k -- map h -- map l vim.keymap.set(all, "", "j") vim.keymap.set(all, "", "k") vim.keymap.set(all, "", "h") vim.keymap.set(all, "", "l") -- ============================================================================ -- User functions to just make life easier -- ============================================================================ -- Creates the directory for a file if it doesn't already exist. bufWritePres = vim.cmd [[ function! s:MkNonExDir(file, buf) if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/' let dir=fnamemodify(a:file, ':h') if !isdirectory(dir) call mkdir(dir, 'p') endif endif endfunction augroup BWCCreateDir autocmd! autocmd BufWritePre * :call s:MkNonExDir(expand(''), +expand('')) augroup END ]] -- Return indent (all whitespace at start of a line), converted from -- tabs to spaces if what = 1, or from spaces to tabs otherwise. -- When converting to tabs, result has no redundant spaces. vim.cmd [[ function! Indenting(indent, what, cols) let spccol = repeat(' ', a:cols) let result = substitute(a:indent, spccol, '\t', 'g') let result = substitute(result, ' \+\ze\t', ''', 'g') if a:what == 1 let result = substitute(result, '\t', spccol, 'g') endif return result endfunction ]] --Convert whitespace used for indenting (before first non-whitespace). --what = 0 (convert spaces to tabs), or 1 (convert tabs to spaces). --cols = string with number of columns per tab, or empty to use 'tabstop'. --The cursor position is restored, but the cursor will be in a different --column when the number of characters in the indent of the line is changed. vim.cmd [[ function! IndentConvert(line1, line2, what, cols) let savepos = getpos('.') let cols = empty(a:cols) ? &tabstop : a:cols execute a:line1 . ',' . a:line2 . 's/^\s\+/\=Indenting(submatch(0), a:what, cols)/e' call histdel('search', -1) call setpos('.', savepos) endfunction command! -nargs=? -range=% Space2Tab call IndentConvert(,,0,) command! -nargs=? -range=% Tab2Space call IndentConvert(,,1,) command! -nargs=? -range=% RetabIndent call IndentConvert(,,&et,) ]]