Browse Source

Tue 19 Jul 2022 18:13:37 ACST

master
Tovi Jaeschke-Rogers 2 years ago
parent
commit
708133b2a2
5 changed files with 142 additions and 0 deletions
  1. +33
    -0
      .config/nvim/lua/general/autocmd.lua
  2. +30
    -0
      .config/nvim/lua/general/options.lua
  3. +35
    -0
      .config/nvim/lua/general/remaps.lua
  4. +19
    -0
      .config/nvim/lua/helper/toggle-tab-width.lua
  5. +25
    -0
      .config/nvim/lua/packer-plugins.lua

+ 33
- 0
.config/nvim/lua/general/autocmd.lua View File

@ -0,0 +1,33 @@
-- Remove any trailing whitespace from the file on write
vim.api.nvim_create_autocmd({ 'BufWritePre' }, { command = [[%s/\s\+$//e]] })
-- Load file on last line
-- TODO: change this to use lua
vim.api.nvim_create_autocmd({ 'BufRead' }, {
command = [[if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]]
})
-- Save session on VimLeave
vim.api.nvim_create_autocmd({ 'VimLeave' }, {
command = [[mksession! ~/.config/nvim/session/shutdown_session.vim]]
})
-- Set tabs to 2 for dart, vue, and js files
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
pattern = { '*.dart', '*.vue', '*.js' },
callback = function()
vim.o.tabstop = 2
vim.o.softtabstop = 2
vim.o.shiftwidth = 2
end
})
-- Ensure to read .docker files as a dockerfile
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
pattern = { '*.docker' },
callback = function()
vim.o.syntax = 'dockerfile'
end
})

+ 30
- 0
.config/nvim/lua/general/options.lua View File

@ -0,0 +1,30 @@
vim.g.mapleader = ','
vim.o.clipboard = 'unnamedplus'
vim.o.nohlsearch = true
vim.o.incsearch = true
vim.o.ignorecase = true
-- autocmd BufWritePre * :%s/\s\+$//e
vim.o.mouse = 'a'
vim.o.smartcase = true
vim.o.linebreak = true
vim.o.noswapfile = true
vim.o.nobackup = true
vim.o.undodir = vim.fn.expand('~/.config/nvim/undodir')
vim.o.undofile = true
vim.o.encoding = 'utf-8'
vim.o.number = true
vim.o.relativenumber = true
vim.o.tabstop = 4
vim.o.softtabstop = 4
vim.o.expandtab = true
vim.o.shiftwidth = 4
vim.o.smarttab = true
vim.o.formatoptions = 'tqj'

+ 35
- 0
.config/nvim/lua/general/remaps.lua View File

@ -0,0 +1,35 @@
local options = { noremap = true }
vim.api.nvim_set_keymap('n', 'c', '"_c', options)
-- Easily open splits
vim.api.nvim_set_keymap('n', '<leader>hs', '<cmd>split<cr>', options)
vim.api.nvim_set_keymap('n', '<leader>vs', '<cmd>vsplit<cr>', options)
-- Copy the entire file
vim.api.nvim_set_keymap('n', '<leader>y', 'ggyG<C-o>', options)
-- Easily navigate tabs
vim.api.nvim_set_keymap('n', '<leader>1', '1gt', options)
vim.api.nvim_set_keymap('n', '<leader>2', '2gt', options)
vim.api.nvim_set_keymap('n', '<leader>3', '3gt', options)
vim.api.nvim_set_keymap('n', '<leader>4', '4gt', options)
vim.api.nvim_set_keymap('n', '<leader>5', '5gt', options)
-- Manually store session
vim.api.nvim_set_keymap('n', '<F5>', '<cmd>mksession! ~/.config/nvim/session/manual_session.vim<cr>', options)
-- Restore manually stored session
vim.api.nvim_set_keymap('n', '<F6>', '<cmd>source ~/.config/nvim/session/manual_session.vim<cr>', options)
-- Restore auto saved session created on exit
vim.api.nvim_set_keymap('n', '<F7>', '<cmd>source ~/.config/nvim/session/shutdown_session.vim<CR>', options)
-- Replace all is aliased to S.
vim.api.nvim_set_keymap('n', '<C-s>', '<cmd>%s//g<Left><Left>', options)
-- Navigating with guides
vim.api.nvim_set_keymap('n', '<leader><leader>', '<Esc>/<++><Enter>"_c4l', options)
vim.api.nvim_set_keymap('i', '<leader><leader>', '<Esc>/<++><Enter>"_c4l', options)
vim.api.nvim_set_keymap('v', '<leader><leader>', '<Esc>/<++><Enter>"_c4l', options)
-- Spell-check
vim.api.nvim_set_keymap('n', '<leader>o', '<cmd>setlocal spell! spelllang=en_au<cr>', options)

+ 19
- 0
.config/nvim/lua/helper/toggle-tab-width.lua View File

@ -0,0 +1,19 @@
local tabWidth = 4
function ToggleTabWidth()
if tabWidth == 2 then
vim.o.tabstop = 4
vim.o.softtabstop = 4
vim.o.shiftwidth = 4
tabWidth = 4
print('Set tab width to 4')
return
end
vim.o.tabstop = 2
vim.o.softtabstop = 2
vim.o.shiftwidth = 2
tabWidth = 2
print('Set tab width to 2')
end
vim.keymap.set('n', '<leader>t', ToggleTabWidth, { noremap = true})

+ 25
- 0
.config/nvim/lua/packer-plugins.lua View File

@ -0,0 +1,25 @@
return require('packer').startup(function()
-- Packer can manage itself
use 'wbthomason/packer.nvim'
-- colorscheme
use 'gruvbox-community/gruvbox'
use { 'neoclide/coc.nvim', run = 'yarn install' }
use 'nvim-lua/popup.nvim'
use 'nvim-lua/plenary.nvim'
use 'nvim-telescope/telescope.nvim'
use 'nvim-telescope/telescope-fzy-native.nvim'
use 'Rican7/php-doc-modded'
use 'f-person/git-blame.nvim'
use 'dart-lang/dart-vim-plugin'
use { 'fatih/vim-go', cmd = 'GoUpdateBinaries' }
use { 'darrikonn/vim-gofmt', cmd = 'GoUpdateBinaries' }
use 'aserowy/tmux.nvim'
end)

Loading…
Cancel
Save