speedie-nvim | Add new config
This commit is contained in:
parent
4fe1a89226
commit
d06714a679
|
@ -1,95 +0,0 @@
|
||||||
" speedie's neovim configuration
|
|
||||||
" purely for productivity, no bloat
|
|
||||||
|
|
||||||
syntax on
|
|
||||||
|
|
||||||
set rnu
|
|
||||||
set mouse=a
|
|
||||||
set clipboard=unnamedplus
|
|
||||||
set title
|
|
||||||
set hidden
|
|
||||||
set smarttab
|
|
||||||
set autoindent
|
|
||||||
set expandtab
|
|
||||||
set noswapfile
|
|
||||||
set nocursorline
|
|
||||||
set laststatus=0
|
|
||||||
set undolevels=10000
|
|
||||||
set softtabstop=4
|
|
||||||
set shiftwidth=4
|
|
||||||
set tabstop=4
|
|
||||||
set spelllang=en_us
|
|
||||||
set spellsuggest=best,5
|
|
||||||
set foldmethod=indent
|
|
||||||
set laststatus=0
|
|
||||||
|
|
||||||
set termguicolors
|
|
||||||
set t_Co=256
|
|
||||||
set t_ut=
|
|
||||||
set background=dark
|
|
||||||
colorscheme elflord
|
|
||||||
|
|
||||||
fu! SaveSession()
|
|
||||||
execute 'mksession! ' . getcwd() . '/.session.nvim'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
fu! RestoreSession()
|
|
||||||
if argc() == 0
|
|
||||||
if filereadable(getcwd() . '/.session.nvim')
|
|
||||||
execute 'so ' . getcwd() . '/.session.nvim'
|
|
||||||
if bufexists(1)
|
|
||||||
for l in range(1, bufnr('$'))
|
|
||||||
if zufwinnr(l) == -1
|
|
||||||
exec 'sbuffer ' . l
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
silent execute '!rm -f ' . getcwd() . '/.session.nvim'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
autocmd BufReadPre *.md set spell
|
|
||||||
autocmd BufWritePre * %s/\s\+$//e
|
|
||||||
autocmd BufWritePre * %s/\t/ /e
|
|
||||||
autocmd BufWritePre Makefile %s/ /\t/e
|
|
||||||
autocmd VimLeave * call SaveSession()
|
|
||||||
autocmd VimEnter * nested call RestoreSession()
|
|
||||||
|
|
||||||
highlight Normal ctermfg=grey ctermbg=lightgray guifg=#ffffff guibg=#222222
|
|
||||||
highlight Folded ctermfg=grey ctermbg=lightgray guifg=#afeeee guibg=#333333
|
|
||||||
highlight SpellBad guisp=red gui=undercurl guifg=none guibg=none ctermfg=none ctermbg=none term=underline cterm=undercurl
|
|
||||||
highlight SpellCap guisp=yellow gui=undercurl guifg=none guibg=none ctermfg=none ctermbg=none term=underline cterm=undercurl
|
|
||||||
|
|
||||||
filetype plugin indent on
|
|
||||||
|
|
||||||
nnoremap <C-h> <C-w>h
|
|
||||||
nnoremap <C-j> <C-w>j
|
|
||||||
nnoremap <C-k> <C-w>k
|
|
||||||
nnoremap <C-l> <C-w>l
|
|
||||||
nnoremap <C-s> :split<cr>
|
|
||||||
nnoremap <C-w> :vsplit<cr>
|
|
||||||
nnoremap <C-q> :only<cr>
|
|
||||||
nnoremap <C-t> :term<cr>
|
|
||||||
|
|
||||||
nnoremap <F2> :set spell!<cr>
|
|
||||||
nnoremap <F3> :set spelllang=en_us<cr>
|
|
||||||
nnoremap <F4> :set spelllang=sv_se<cr>
|
|
||||||
nnoremap <F7> :silent execute '!setxkbmap us'<cr>
|
|
||||||
nnoremap <F8> :silent execute '!setxkbmap se'<cr>
|
|
||||||
nnoremap <C-e> [s1z=
|
|
||||||
nnoremap <C-r> 1z=
|
|
||||||
|
|
||||||
nnoremap H :vertical resize -10<cr>
|
|
||||||
nnoremap J :resize -10<cr>
|
|
||||||
nnoremap K :resize +10<cr>
|
|
||||||
nnoremap L :vertical resize +10<cr>
|
|
||||||
|
|
||||||
nnoremap d "_d
|
|
||||||
xnoremap d "_d
|
|
||||||
xnoremap p "_dP
|
|
||||||
nnoremap c "_c
|
|
||||||
|
|
||||||
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
|
|
||||||
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
|
|
120
.config/nvim/init.lua
Normal file
120
.config/nvim/init.lua
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
--[[
|
||||||
|
speedie's neovim configuration
|
||||||
|
-- https://git.speedie.site/speedie/speedie-nvim --
|
||||||
|
]]--
|
||||||
|
|
||||||
|
local cmd = vim.cmd
|
||||||
|
local opt = vim.opt
|
||||||
|
local o = vim.o
|
||||||
|
local api = vim.api
|
||||||
|
local keymap = vim.api.nvim_set_keymap
|
||||||
|
local autocmd = vim.api.nvim_create_autocmd
|
||||||
|
local sessionFile = vim.fn.expand('~/.config/nvim/.session.nvim')
|
||||||
|
|
||||||
|
opt.title = true -- Display title
|
||||||
|
opt.spelllang = 'en_us' -- Use English (United States) as spellcheck language by default
|
||||||
|
opt.relativenumber = true -- Show relative line numbers
|
||||||
|
opt.mouse = 'a' -- Enable mouse
|
||||||
|
opt.clipboard = 'unnamedplus' -- Use system clipboard
|
||||||
|
opt.hidden = true -- Hides buffers
|
||||||
|
opt.smarttab = true -- Enable smart tab
|
||||||
|
opt.ignorecase = true -- Enable case insensitivity when searching
|
||||||
|
opt.smartcase = true -- Pretty much same for this one
|
||||||
|
opt.hlsearch = false -- Don't highlight searches
|
||||||
|
opt.smartindent = true -- Automatically indent the next line
|
||||||
|
opt.autoindent = true -- Pretty much same for this one
|
||||||
|
opt.expandtab = true -- Replace tabs with spaces automatically
|
||||||
|
opt.swapfile = false -- Don't use a swapfile
|
||||||
|
opt.cursorline = false -- Don't show the cursor line
|
||||||
|
opt.undolevels = 10000 -- Allow up to 10000 undos
|
||||||
|
opt.tabstop = 4 -- Display a tab (\t) as 4 spaces
|
||||||
|
opt.softtabstop = 4 -- Display a tab (\t) as 4 spaces
|
||||||
|
opt.shiftwidth = 4 -- Indents for << or >>
|
||||||
|
opt.spellsuggest = 'best,5' -- Prefer the best suggestions
|
||||||
|
opt.foldmethod = 'indent' -- Fold based on indents
|
||||||
|
opt.laststatus = 0 -- Don't display file information
|
||||||
|
opt.termguicolors = true -- Enable true color
|
||||||
|
opt.autochdir = true -- Automatically change directory to the file we're editing
|
||||||
|
opt.background = 'dark' -- Set background to dark
|
||||||
|
|
||||||
|
o.t_8f = '\27[38;2;%lu;%lu;%lum' -- To be honest, I don't know what this does but if I remember correctly it's something good.
|
||||||
|
o.t_8b = '\27[48;2;%lu;%lu;%lum' -- To be honest, I don't know what this does but if I remember correctly it's something good.
|
||||||
|
|
||||||
|
cmd([[
|
||||||
|
colorscheme elflord
|
||||||
|
highlight Normal ctermfg=grey ctermbg=lightgray guifg=#ffffff guibg=#222222
|
||||||
|
highlight Folded ctermfg=grey ctermbg=lightgray guifg=#afeeee guibg=#333333
|
||||||
|
highlight SpellBad guisp=red gui=undercurl guifg=none guibg=none ctermfg=none ctermbg=none term=underline cterm=undercurl
|
||||||
|
highlight SpellCap guisp=yellow gui=undercurl guifg=none guibg=none ctermfg=none ctermbg=none term=underline cterm=undercurl
|
||||||
|
filetype plugin indent on
|
||||||
|
]])
|
||||||
|
|
||||||
|
keymap('n', '<C-h>', '<C-w>h', { noremap = true })
|
||||||
|
keymap('n', '<C-j>', '<C-w>j', { noremap = true })
|
||||||
|
keymap('n', '<C-k>', '<C-w>k', { noremap = true })
|
||||||
|
keymap('n', '<C-l>', '<C-w>l', { noremap = true })
|
||||||
|
keymap('n', '<C-s>', ':split<CR>', { noremap = true })
|
||||||
|
keymap('n', '<C-w>', ':vsplit<CR>', { noremap = true })
|
||||||
|
keymap('n', '<C-q>', ':only<CR>', { noremap = true })
|
||||||
|
keymap('n', '<C-t>', ':term<CR>', { noremap = true })
|
||||||
|
keymap('n', '<F2>', ':set spell!<CR>', { noremap = true })
|
||||||
|
keymap('n', '<F3>', ':set spelllang=en_us<CR>', { noremap = true })
|
||||||
|
keymap('n', '<F4>', ':set spelllang=sv_se<CR>', { noremap = true })
|
||||||
|
keymap('n', '<F7>', ':silent execute "!setxkbmap us"<CR>', { noremap = true })
|
||||||
|
keymap('n', '<F8>', ':silent execute "!setxkbmap se"<CR>', { noremap = true })
|
||||||
|
keymap('n', '<C-e>', '[s1z=', { noremap = true })
|
||||||
|
keymap('n', '<C-r>', '1z=', { noremap = true })
|
||||||
|
keymap('n', '<C-b>', ':!ninja -C build<CR>', { noremap = true })
|
||||||
|
keymap('n', 'H', ':vertical resize -10<CR>', { noremap = true })
|
||||||
|
keymap('n', 'J', ':resize -10<CR>', { noremap = true })
|
||||||
|
keymap('n', 'K', ':resize +10<CR>', { noremap = true })
|
||||||
|
keymap('n', 'L', ':vertical resize +10<CR>', { noremap = true })
|
||||||
|
keymap('n', 'd', '"_d', { noremap = true })
|
||||||
|
keymap('x', 'd', '"_d', { noremap = true })
|
||||||
|
keymap('x', 'p', '"_dP', { noremap = true })
|
||||||
|
keymap('n', 'c', '"_c', { noremap = true })
|
||||||
|
keymap('n', '<C-A>', 'v/{<cr>%', { noremap = true })
|
||||||
|
|
||||||
|
function saveSession() -- Save the current session
|
||||||
|
vim.cmd('mksession! ' .. sessionFile)
|
||||||
|
end
|
||||||
|
|
||||||
|
function restoreSession() -- Restore the last session
|
||||||
|
if vim.fn.argc() == 0 then
|
||||||
|
if vim.fn.filereadable(sessionFile) == 1 then
|
||||||
|
vim.cmd('source ' .. sessionFile)
|
||||||
|
vim.cmd("filetype detect")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
autocmd('BufWritePre', { -- Remove trailing spaces
|
||||||
|
pattern = { '*' },
|
||||||
|
callback = function()
|
||||||
|
vim.cmd("%s/\\s\\+$//e")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
autocmd('BufReadPre', { -- Enable spell check for all Markdown files
|
||||||
|
pattern = { '*.md' },
|
||||||
|
callback = function()
|
||||||
|
vim.cmd("set spell")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
autocmd('BufWritePre', { -- Replace four spaces with tabs in Makefiles
|
||||||
|
pattern = { 'Makefile' },
|
||||||
|
callback = function()
|
||||||
|
vim.cmd("autocmd BufWritePre Makefile %s/ /\t/e")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
autocmd('VimEnter', { -- Restore session on load
|
||||||
|
pattern = { '*' },
|
||||||
|
callback = function()
|
||||||
|
restoreSession()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
autocmd('VimLeave', { -- Save session on exit
|
||||||
|
pattern = { '*' },
|
||||||
|
callback = function()
|
||||||
|
saveSession()
|
||||||
|
end,
|
||||||
|
})
|
|
@ -1 +0,0 @@
|
||||||
source $HOME/.config/nvim/config
|
|
|
@ -4,7 +4,7 @@ if [ -e "$HOME/.config/nvim" ]; then
|
||||||
rm -rf .config/nvim
|
rm -rf .config/nvim
|
||||||
mkdir -p .config
|
mkdir -p .config
|
||||||
cp -r $HOME/.config/nvim .config/
|
cp -r $HOME/.config/nvim .config/
|
||||||
rm -rf .config/nvim/vimdata .config/nvim/.session.nvim
|
rm -rf .config/nvim/.session.nvim
|
||||||
|
|
||||||
git add .config/* commit.sh install.sh
|
git add .config/* commit.sh install.sh
|
||||||
git commit -a -m "speedie-nvim | Add new config"
|
git commit -a -m "speedie-nvim | Add new config"
|
||||||
|
|
Loading…
Reference in a new issue