From 626bcd4ce47e40fa5bdd7a0c96fb1be1dbc8f0f1 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 30 Oct 2021 22:00:53 +0100 Subject: [PATCH] refactor(nvim): move more settings to lua --- nvim/.config/nvim/init.vim | 8 --- nvim/.config/nvim/lua/opdavies/init.lua | 74 ++++++++++++++++++------- nvim/.config/nvim/plugins/mappings.vim | 26 --------- 3 files changed, 53 insertions(+), 55 deletions(-) diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 450d545..d07451c 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -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 diff --git a/nvim/.config/nvim/lua/opdavies/init.lua b/nvim/.config/nvim/lua/opdavies/init.lua index 6e98d91..bf8d671 100644 --- a/nvim/.config/nvim/lua/opdavies/init.lua +++ b/nvim/.config/nvim/lua/opdavies/init.lua @@ -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', 'so', ':so ~/.config/nvim/init.vim', options) + +-- Make the current file executable +vim.api.nvim_set_keymap('n', 'x', ':!chmod +x %', 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', '', '', options) +vim.api.nvim_set_keymap('v', '', '', options) +vim.api.nvim_set_keymap('v', '', '', options) +vim.api.nvim_set_keymap('v', '', '', options) + +vim.api.nvim_set_keymap('n', 'k', ':nohlsearch', options) require "opdavies.plugins.colours" require "opdavies.plugins.completion" require "opdavies.plugins.floaterm" diff --git a/nvim/.config/nvim/plugins/mappings.vim b/nvim/.config/nvim/plugins/mappings.vim index 8c3476a..d4c9689 100644 --- a/nvim/.config/nvim/plugins/mappings.vim +++ b/nvim/.config/nvim/plugins/mappings.vim @@ -1,29 +1,3 @@ -" Source the current file -nnoremap so :so ~/.config/nvim/init.vim - -" Make the current file executable -nnoremap x :!chmod +x % - -" Yank from the current column to the end of the line -nnoremap Y yg$ - -" Move lines up and down -inoremap :m .+1==gi -inoremap :m .-2==gi -vnoremap :m '<-2gv=gv -vnoremap :m '>+1gv=gv - -" Keep things centred -nnoremap n nzzzv -nnoremap N Nzzzv - -" Remove arrow keys -noremap -noremap -noremap -noremap - " Clears hlsearch after doing a search, otherwise just does normal stuff -nnoremap {-> v:hlsearch ? ":nohl\" : "\"}() nnoremap :silent !tmux neww tmux-sessioniser