neovim: basic new config in lua

This commit is contained in:
FollieHiyuki 2021-07-04 03:19:46 +03:00
parent 01ff68ac92
commit 4d7b08e6ec
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
13 changed files with 329 additions and 0 deletions

View File

@ -31,6 +31,7 @@
### :star2: Credits
- [@glepnir](https://github.com/glepnir/nvim)'s Neovim config
- [@hlissner](https://github.com/hlissner)'s zsh config
- [@daviwil](https://github.com/daviwil)'s/[@tecosaur](https://tecosaur.github.io/emacs-config/config.html)'s Emacs configurations
- [@begs](https://git.sr.ht/~begs/dotfiles)'s Waybar config

View File

@ -0,0 +1,15 @@
setlocal autoindent
setlocal conceallevel=0
setlocal expandtab
setlocal foldmethod=syntax
setlocal formatoptions=tcq2l
setlocal shiftwidth=4
setlocal softtabstop=4
setlocal tabstop=8
let s:bufname = expand('%:e')
if s:bufname && s:bufname ==# 'jsonschema'
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal tabstop=4
endif

View File

@ -0,0 +1,8 @@
setlocal autoindent
setlocal conceallevel=0
setlocal expandtab
setlocal foldmethod=syntax
setlocal formatoptions=tcq2l
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal tabstop=4

View File

@ -0,0 +1,6 @@
setlocal noexpandtab
" https://mattn.kaoriya.net/software/vim/20070821175457.htm
setlocal isfname-== isfname+=32 isfname-=I isfname-=L
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal tabstop=2

View File

@ -0,0 +1,2 @@
setlocal wrap
setlocal nonumber norelativenumber

View File

@ -0,0 +1,2 @@
setlocal wrap
setlocal nonumber norelativenumber

View File

@ -0,0 +1,3 @@
setlocal colorcolumn=120
setlocal iskeyword+=:,#
setlocal tags+=$DATA_PATH/tags

View File

@ -0,0 +1,7 @@
setlocal autoindent
setlocal expandtab
setlocal indentkeys-=<:>
setlocal iskeyword+=-,$,#
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal tabstop=2

View File

@ -0,0 +1,36 @@
local disable_distribution_plugins = function()
vim.g.loaded_gzip = 1
vim.g.loaded_tar = 1
vim.g.loaded_tarPlugin = 1
vim.g.loaded_zip = 1
vim.g.loaded_zipPlugin = 1
vim.g.loaded_getscript = 1
vim.g.loaded_getscriptPlugin = 1
vim.g.loaded_vimball = 1
vim.g.loaded_vimballPlugin = 1
vim.g.loaded_matchit = 1
vim.g.loaded_matchparen = 1
vim.g.loaded_2html_plugin = 1
vim.g.loaded_logiPat = 1
vim.g.loaded_rrhelper = 1
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.g.loaded_netrwSettings = 1
vim.g.loaded_netrwFileHandlers = 1
end
local leader_map = function()
vim.g.mapleader = ' '
vim.api.nvim_set_keymap('n',' ','',{noremap = true})
vim.api.nvim_set_keymap('x',' ','',{noremap = true})
end
local load_core = function()
require('options')
disable_distribution_plugins()
leader_map()
require('plugins')
require('events').load_autocmds()
end
load_core()

View File

@ -0,0 +1,65 @@
local plug_dir = vim.fn.stdpath('config') .. '/lua'
local M = {}
function M.packer_compile()
local file = vim.fn.expand('%:p')
if file:match(plug_dir) then
vim.api.nvim_command('PackerCompile')
end
end
function M.nvim_create_augroups(definitions)
for group_name, definition in pairs(definitions) do
vim.api.nvim_command('augroup '..group_name)
vim.api.nvim_command('autocmd!')
for _, def in ipairs(definition) do
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
vim.api.nvim_command(command)
end
vim.api.nvim_command('augroup END')
end
end
function M.load_autocmds()
local definitions = {
packer = {
{"BufWritePost", "*.lua", "lua require('events').packer_compile()"};
};
-- Edit binary files in hex with xxd (:%!xxd and :%!xxd -r)
-- or using nvim -b to edit files using xxd-format
binary = {
{"BufReadPre" , "*.bin,*.exe", "let &bin=1"};
{"BufReadPost" , "*.bin,*.exe", "if &bin | %!xxd"};
{"BufReadPost" , "*.bin,*.exe", "set ft=xxd | endif"};
{"BufWritePre" , "*.bin,*.exe", "if &bin | %!xxd -r"};
{"BufWritePre" , "*.bin,*.exe", "endif"};
{"BufWritePost", "*.bin,*.exe", "if &bin | %!xxd"};
{"BufWritePost", "*.bin,*.exe", "set nomod | endif"};
};
document = {
{"BufNewFile,BufEnter,BufRead", "*.md,*.mkd", "setfiletype markdown"};
{"BufNewFile,BufEnter,BufRead", "*.tex", "setfiletype tex"};
{"BufNewFile,BufRead", "*.md,*.mkd", "setlocal spell"};
{"BufNewFile,BufRead", "*.tex", "setlocal spell"};
};
wins = {
-- Equalize window dimensions when resizing vim window
{"VimResized", "*", [[tabdo wincmd =]]};
-- Force write shada on leaving nvim
{"VimLeave", "*", [[if has('nvim') | wshada! | else | wviminfo! | endif]]};
-- Check if file changed when its window is focus, more eager than 'autoread'
{"FocusGained", "* checktime"};
};
yank = {
{"TextYankPost", [[* silent! lua vim.highlight.on_yank({higroup="IncSearch", timeout=300})]]};
};
}
M.nvim_create_augroups(definitions)
end
return M

View File

@ -0,0 +1,10 @@
local function nord_options()
vim.g.nord_contrast = true
vim.g.nord_borders = true
vim.g.nord_disable_background = false
vim.g.nord_cursorline_transparent = false
require('nord').set()
end
nord_options()

View File

@ -0,0 +1,130 @@
local opt = vim.opt
local function load_options()
-- General settings
opt.termguicolors = true;
-- opt.background = 'dark';
opt.mouse = 'nv';
opt.errorbells = false;
opt.visualbell = false;
opt.hidden = true;
opt.fileformats = 'unix';
opt.magic = true;
opt.virtualedit = 'block';
opt.encoding = 'utf-8';
opt.fileencoding = 'utf-8';
opt.clipboard = 'unnamedplus';
opt.wildignorecase = true;
opt.wildignore = '.git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store,**/node_modules/**';
opt.history = 1000;
opt.showmode = false;
opt.jumpoptions = 'stack';
opt.formatoptions = '1jcroql';
opt.shortmess = 'aoOTIcF';
opt.startofline = false;
opt.wrap = false;
opt.sidescrolloff = 4;
opt.scrolloff = 4;
opt.whichwrap = '<,>,[,],~';
opt.ruler = true;
opt.display = 'lastline';
-- opt.colorcolumn = '80';
-- opt.cursorline = true;
-- opt.backspace = 'indent,eol,start';
opt.showcmd = false;
opt.cmdheight = 2;
opt.cmdwinheight = 6;
opt.showtabline = 2;
opt.laststatus = 2;
opt.textwidth = 80;
opt.synmaxcol = 2500;
-- opt.shell = 'bash';
opt.grepformat = '%f:%l:%c:%m';
opt.grepprg = 'rg --hidden --vimgrep --smart-case --';
opt.diffopt = 'filler,iwhite,internal,algorithm:patience';
-- Transparency
opt.pumblend = 10;
opt.winblend = 10;
-- Conceal
opt.conceallevel = 2;
opt.concealcursor = 'niv';
-- opt.foldenable = true;
opt.foldlevelstart = 99;
-- Case insensitive
opt.ignorecase = true;
opt.smartcase = true;
opt.infercase = true;
-- Searching
opt.incsearch = true;
opt.hlsearch = false;
-- opt.wrapscan = true;
-- Update time
opt.timeout = true;
opt.ttimeout = true;
opt.timeoutlen = 300;
opt.ttimeoutlen = 10;
opt.updatetime = 150;
opt.redrawtime = 1500;
-- No swapfile
opt.backup = false;
opt.writebackup = false;
opt.swapfile = false;
-- Completion menu
opt.wildmenu = true;
opt.wildmode = 'full';
opt.complete = '.,w,b,k';
opt.completeopt = 'menuone,noselect';
opt.pumheight = 16;
opt.helpheight = 12;
opt.previewheight = 12;
-- Window rules
opt.splitbelow = true;
opt.splitright = true;
opt.inccommand = 'nosplit';
opt.switchbuf = 'useopen';
opt.winwidth = 30;
opt.winminwidth = 10;
opt.equalalways = false;
-- Left column
opt.signcolumn = 'yes';
opt.number = true;
opt.relativenumber = true;
opt.numberwidth = 4;
-- 4 spaces = 1 tab
opt.tabstop = 4;
opt.softtabstop = 4;
opt.shiftwidth = 4;
opt.smarttab = true;
opt.expandtab = true;
opt.smartindent = true;
opt.autoindent = true;
opt.shiftround = true;
-- Trailings, line break
opt.list = true;
opt.listchars = 'tab:»·,nbsp:+,trail:·,extends:→,precedes:←';
opt.showbreak = '';
opt.linebreak = true;
opt.breakat = [[\ \ ;:,!?]];
-- opt.breakindentopt = 'shift:4,min:20';
-- Undo file path
opt.undofile = true;
opt.undodir = vim.fn.stdpath('data') .. '/undodir'
-- Python path
vim.g.python_host_prog = '/usr/bin/python'
vim.g.python3_host_prog = '/usr/bin/python3'
end
load_options()

View File

@ -0,0 +1,44 @@
local fn,api = vim.fn,vim.api
local packer_dir = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(packer_dir)) > 0 then
fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_dir})
api.nvim_command('packadd packer.nvim')
end
local packer = require('packer')
local use = packer.use
return packer.startup(
function()
use 'wbthomason/packer.nvim'
-- Appearance / UI
use {
'shaunsingh/nord.nvim',
config = function()
require('modules.nord')
end
}
use {
'norcalli/nvim-colorizer.lua',
event = 'BufRead',
config = function()
require('colorizer').setup(
{'*';},
{
RGB = true; -- #RGB hex codes
RRGGBB = true; -- #RRGGBB hex codes
names = true; -- "Name" codes like Blue
RRGGBBAA = true; -- #RRGGBBAA hex codes
rgb_fn = true; -- CSS rgb() and rgba() functions
hsl_fn = true; -- CSS hsl() and hsla() functions
css = true; -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true; -- Enable all CSS *functions*: rgb_fn, hsl_fn
mode = 'background'; -- Set the display mode.
})
vim.cmd('ColorizerReloadAllBuffers')
end
}
end
)