refactor(nvim): move more settings to lua

This commit is contained in:
Oliver Davies 2021-10-30 22:00:53 +01:00
parent 396fab57da
commit 626bcd4ce4
3 changed files with 53 additions and 55 deletions

View file

@ -16,13 +16,5 @@ endfunction
call s:LoadPlugins()
call s:SourceConfigFilesIn('plugins')
autocmd FileType gitcommit highlight ColorColumn ctermbg=8
autocmd FileType gitcommit setlocal colorcolumn=50,72
autocmd FileType gitcommit setlocal textwidth=72
autocmd FileType gitcommit setlocal spell
lua require("opdavies")
highlight Comment cterm=italic gui=italic
autocmd BufRead,BufNewFile *.test set filetype=php

View file

@ -1,29 +1,61 @@
vim.g.mapleader = ' '
vim.cmd('filetype indent on')
vim.cmd('filetype on')
vim.cmd('filetype plugin on')
vim.cmd('syntax on')
vim.cmd 'autocmd BufRead,BufNewFile *.test set filetype=php'
vim.cmd 'autocmd FileType gitcommit highlight ColorColumn ctermbg=8'
vim.cmd 'autocmd FileType gitcommit setlocal colorcolumn=50,72'
vim.cmd 'autocmd FileType gitcommit setlocal spell'
vim.cmd 'autocmd FileType gitcommit setlocal textwidth=72'
vim.cmd 'filetype indent on'
vim.cmd 'filetype on'
vim.cmd 'filetype plugin on'
vim.cmd 'highlight Comment cterm=italic gui=italic'
vim.cmd 'syntax on'
vim.o.autoindent = true
vim.o.breakindent = true
vim.o.expandtab = true
vim.o.foldmethod = 'indent'
vim.o.formatoptions = 'lm'
vim.o.linebreak = true
vim.o.mouse = 'n'
vim.o.number = true
vim.o.relativenumber = true
vim.o.scrolloff = 10
vim.o.shiftwidth = 2
vim.o.smartindent = true
vim.o.softtabstop = 2
vim.o.swapfile = false
vim.o.tabstop = 2
vim.o.termguicolors = true
vim.o.updatetime = 1000
vim.o.wrap = true
vim.opt.autoindent = true
vim.opt.breakindent = true
vim.opt.clipboard:append 'unnamedplus'
vim.opt.expandtab = true
vim.opt.foldmethod = 'indent'
vim.opt.formatoptions = 'lm'
vim.opt.linebreak = true
vim.opt.mouse = 'n'
vim.opt.number = true
vim.opt.scrolloff = 10
vim.opt.shiftwidth = 2
vim.opt.smartindent = true
vim.opt.softtabstop = 2
vim.opt.swapfile = false
vim.opt.tabstop = 2
vim.opt.termguicolors = true
vim.opt.updatetime = 1000
vim.opt.wrap = true
local options = { noremap = true }
vim.api.nvim_set_keymap('n', '<Leader>so', ':so ~/.config/nvim/init.vim<Cr>', options)
-- Make the current file executable
vim.api.nvim_set_keymap('n', '<Leader>x', ':!chmod +x %<Cr>', options)
-- Yank from the current column to the end of the line
vim.api.nvim_set_keymap('n', 'Y', 'yg$', options)
-- Keep things centred
vim.api.nvim_set_keymap('n', 'n', 'nzzzv', options)
vim.api.nvim_set_keymap('n', 'N', 'Nzzzv', options)
-- Remove arrow keys
vim.api.nvim_set_keymap('v', '<down>', '<nop>', options)
vim.api.nvim_set_keymap('v', '<left>', '<nop>', options)
vim.api.nvim_set_keymap('v', '<right>', '<nop>', options)
vim.api.nvim_set_keymap('v', '<up>', '<nop>', options)
vim.api.nvim_set_keymap('n', '<Leader>k', ':nohlsearch', options)
require "opdavies.plugins.colours"
require "opdavies.plugins.completion"
require "opdavies.plugins.floaterm"

View file

@ -1,29 +1,3 @@
" Source the current file
nnoremap <Leader>so :so ~/.config/nvim/init.vim<CR>
" Make the current file executable
nnoremap <Leader>x :!chmod +x %<CR>
" Yank from the current column to the end of the line
nnoremap Y yg$
" Move lines up and down
inoremap <M-j> <Esc>:m .+1<CR>==gi
inoremap <M-k> <Esc>:m .-2<CR>==gi
vnoremap <M-k> :m '<-2<CR>gv=gv
vnoremap <M-j> :m '>+1<CR>gv=gv
" Keep things centred
nnoremap n nzzzv
nnoremap N Nzzzv
" Remove arrow keys
noremap <up> <nop>
noremap <down> <nop>
noremap <left> <nop>
noremap <right> <nop>
" Clears hlsearch after doing a search, otherwise just does normal <CR> stuff
nnoremap <expr> <CR> {-> v:hlsearch ? ":nohl\<CR>" : "\<CR>"}()
nnoremap <silent> <C-f> :silent !tmux neww tmux-sessioniser<CR>