From: Ruben Beltran del Rio Date: Tue, 18 Jul 2023 19:25:13 +0000 (+0200) Subject: Replace vimscript config with lua X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/commitdiff_plain/ce3499096aaf5e54830b99f64ecf159e9809c644?hp=a78545aee0d150b7032e567e92e57fd0d3e83d6d Replace vimscript config with lua --- diff --git a/config/nvim/init.lua b/config/nvim/init.lua new file mode 100644 index 0000000..02f5bd5 --- /dev/null +++ b/config/nvim/init.lua @@ -0,0 +1,127 @@ +------------------------------------------------------------------------------- +-- Style +------------------------------------------------------------------------------- +-- Editor Style +vim.opt.number = true -- Show number column +vim.opt.wrap = false -- Don't wrap text +vim.opt.list = true -- Display tabs and trailing space +vim.opt.colorcolumn='80,150' -- Show color columns + +-- Color +vim.opt.termguicolors = true +vim.cmd.color('rbdr') + +-- Tab Style (Always override with editorconfig) +vim.opt.tabstop = 2 -- 2 Spaces per tab +vim.opt.shiftwidth = 2 -- Spaces used in Autoindent +vim.opt.softtabstop = 2 -- Spaces used when soft tabbing +vim.opt.expandtab = true -- Always use spaces + +------------------------------------------------------------------------------- +-- Behavior +------------------------------------------------------------------------------- +-- Search Behavior +vim.opt.ignorecase = true -- Ignore case when searching +vim.opt.smartcase = true -- Unless we use both cases in search + +-- Autocomplete Behavior +vim.opt.wildmode = 'list:longest,list:full' -- Autocomplete common matching string + -- first, and then the full match. + +-- Folding Behavior +vim.opt.foldmethod = 'syntax' -- Use syntax highlight to define folds +vim.opt.foldnestmax = 10 -- Max 10 folds +vim.opt.foldlevelstart = 99 -- Start with all folds open + +-- Relative Number Behavior +vim.api.nvim_create_autocmd({'FocusLost', 'InsertEnter'}, { + pattern = '*', + callback = function () vim.opt.relativenumber = false end, +}) +vim.api.nvim_create_autocmd({'InsertLeave', 'CursorMoved'}, { + pattern = '*', + callback = function () vim.opt.relativenumber = true end, +}) + +vim.keymap.set('n', '', function() + vim.opt.relativenumber = not vim.opt.relativenumber +end) + +-- Move lines / blocks up and down using Ctrl + Shift +vim.keymap.set('n', '', ':m .+1==') +vim.keymap.set('n', '', ':m .-2==') +vim.keymap.set('i', '', ':m .+1==gi') +vim.keymap.set('i', '', ':m .-2==gi') +vim.keymap.set('v', '', ':m \'>+1gv=gv') +vim.keymap.set('v', '', ':m \'<-2gv=gv') + +------------------------------------------------------------------------------- +-- File Specific Behavior +------------------------------------------------------------------------------- +-- Makefiles +vim.api.nvim_create_autocmd({'FileType'}, { + pattern = 'make', + callback = function () vim.opt.expandtab = false end +}) + +-- SNES files +vim.api.nvim_create_autocmd({'BufNewFile', 'BufRead'}, { + pattern = {'*.asm', '*.s'}, + callback = function () vim.opt.filetype = 'snes' end +}) + +------------------------------------------------------------------------------- +-- Local Overrides +------------------------------------------------------------------------------- +pcall(require, 'init_local') + +------------------------------------------------------------------------------- +-- Plugin Specific Behavior +------------------------------------------------------------------------------- +-- FZF +vim.keymap.set('', '', ':FZF ') +vim.g.fzf_layout = { down = '40%' } +vim.g.fzf_colors = { + fg = {'fg', 'Normal'}, + bg = {'bg', 'Normal'}, + hl = {'fg', 'Comment'}, + ['fg+'] = {'fg', 'CursorLine', 'CursorColumn', 'Normal'}, + ['bg+'] = {'bg', 'CursorLine', 'CursorColumn'}, + ['hl+'] = {'fg', 'Statement'}, + info = {'fg', 'PreProc'}, + border = {'fg', 'Ignore'}, + prompt = {'fg', 'Conditional'}, + pointer = {'fg', 'Exception'}, + marker = {'fg', 'Keyword'}, + spinner = {'fg', 'Label'}, + header = {'fg', 'Comment'} +} + + +-- Svelte Config +vim.g.vim_svelte_plugin_use_typescript = true + +-- Limelight / Goyo config + +vim.g.limelight_conceal_ctermfg = 'gray' +vim.g.limelight_conceal_guifg = 'DarkGray' + +vim.api.nvim_create_autocmd({'User'}, { + pattern = 'GoyoEnter', + callback = 'Limelight' +}) +vim.api.nvim_create_autocmd({'User'}, { + pattern = 'GoyoLeave', + callback = 'Limelight!' +}) +--[[ +nnoremap i :Limelight!!== +inoremap i :Limelight!!==gi +vnoremap i :Limelight!!gv=gv +nnoremap g :Goyo== +inoremap g :Goyo==gi +vnoremap g :Goyogv=gv +]]-- + +-- Plugins +require('plugins') diff --git a/config/nvim/init.vim b/config/nvim/init.vim deleted file mode 100644 index 5ab37d7..0000000 --- a/config/nvim/init.vim +++ /dev/null @@ -1,117 +0,0 @@ -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Style -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Editor Style -set number " Show number column -set nowrap " Don't wrap text -set list " Display tabs and trailing space -let &colorcolumn="80,150" " Show color columns - -" Color -set termguicolors -color rbdr - -" Tab Style (Always override with editorconfig) -set tabstop=2 " 2 Spaces per tab -set shiftwidth=2 " Spaces used in Autoindent -set softtabstop=2 " Spaces used when soft tabbing -set expandtab " Always use spaces - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Behavior -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Search Behavior -set ignorecase " Ignore case when searching -set smartcase " Unless we use both cases in search - -" Autocomplete Behavior -set wildmode=list:longest,list:full " Autocomplete common matching string - " first, and then the full match. - -" Folding Behavior -set foldmethod=syntax " Use syntax highlight to define folds -set foldnestmax=10 " Max 10 folds -set foldlevelstart=99 " Start with all folds open - -" Relative Number Behavior -autocmd FocusLost * :set norelativenumber -autocmd InsertEnter * :set norelativenumber -autocmd InsertLeave * :set relativenumber -autocmd CursorMoved * :set relativenumber - -function! NumberToggle() - if(&relativenumber == 1) - set norelativenumber - else - set relativenumber - endif -endfunction - -nnoremap :call NumberToggle() - -" Move lines / blocks up and down using Ctrl + Shift -nnoremap :m .+1== -nnoremap :m .-2== -inoremap :m .+1==gi -inoremap :m .-2==gi -vnoremap :m '>+1gv=gv -vnoremap :m '<-2gv=gv - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" File Specific Behavior -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Makefiles -au FileType make set noexpandtab " Makefiles need real tabs - -" SNES files -au BufNewFile,BufRead *.asm,*.s set filetype=snes" -" - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Local Overrides -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -if filereadable(expand("~/.init.local.vim")) - source ~/.init.local.vim -endif - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Plugin Specific Behavior -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" FZF -set rtp+=$FZF_VIM_PATH " Load FZF vim plugin -noremap :FZF -let g:fzf_layout = { 'down': '40%' } -let g:fzf_colors = -\ { 'fg': ['fg', 'Normal'], - \ 'bg': ['bg', 'Normal'], - \ 'hl': ['fg', 'Comment'], - \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], - \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], - \ 'hl+': ['fg', 'Statement'], - \ 'info': ['fg', 'PreProc'], - \ 'border': ['fg', 'Ignore'], - \ 'prompt': ['fg', 'Conditional'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', 'Label'], - \ 'header': ['fg', 'Comment'] } - -" Svelte Config -let g:vim_svelte_plugin_use_typescript = 1 - -" Limelight / Goyo config - -let g:limelight_conceal_ctermfg = 'gray' -let g:limelight_conceal_guifg = 'DarkGray' - -autocmd! User GoyoEnter Limelight -autocmd! User GoyoLeave Limelight! -nnoremap i :Limelight!!== -inoremap i :Limelight!!==gi -vnoremap i :Limelight!!gv=gv -nnoremap g :Goyo== -inoremap g :Goyo==gi -vnoremap g :Goyogv=gv - -" Plug -runtime plugins.vim diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json new file mode 100644 index 0000000..daaabbf --- /dev/null +++ b/config/nvim/lazy-lock.json @@ -0,0 +1,28 @@ +{ + "LargeFile": { "branch": "master", "commit": "3941a37b2b0288524300348a39521a46539bf9f6" }, + "api-notation.vim": { "branch": "master", "commit": "b6f0708fb9f009b7051db514423e9ebf86bc9af4" }, + "coc.nvim": { "branch": "release", "commit": "bbaa1d5d1ff3cbd9d26bb37cfda1a990494c4043" }, + "dart-vim-plugin": { "branch": "master", "commit": "928302ec931caf0dcf21835cca284ccd2b192f7b" }, + "gemini.vim": { "branch": "master", "commit": "c9efb59c97b71c28d4678c79fd21fbdd3a69d196" }, + "goyo.vim": { "branch": "master", "commit": "fa0263d456dd43f5926484d1c4c7022dfcb21ba9" }, + "kotlin-vim": { "branch": "master", "commit": "53fe045906df8eeb07cb77b078fc93acda6c90b8" }, + "lazy.nvim": { "branch": "main", "commit": "25beed5e2e935ebc00d7e3eed1dc502df3c40e39" }, + "limelight.vim": { "branch": "master", "commit": "86aaec1700b27618d33d6182f44691d84d2cb6e5" }, + "rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, + "snes-syntax-vim": { "branch": "master", "commit": "a6a699c8905f7b6119bf91e44f960667d9f03d59" }, + "typescript-vim": { "branch": "master", "commit": "31ede5ad905ce4159a5e285073a391daa3bf83fa" }, + "vim-closer": { "branch": "master", "commit": "6007d9db0a35e983af246b667282606612076b07" }, + "vim-endwise": { "branch": "master", "commit": "e714ac3bcfd5a90038de49c3254eded7c70ae3c3" }, + "vim-fugitive": { "branch": "master", "commit": "b3b838d690f315a503ec4af8c634bdff3b200aaf" }, + "vim-glsl": { "branch": "master", "commit": "bfd330a271933c3372fcfa8ce052970746c8e9dd" }, + "vim-graphql": { "branch": "master", "commit": "996749a7d69a3709768fa8c4d259f79b5fd9bdb1" }, + "vim-indent-object": { "branch": "master", "commit": "5c5b24c959478929b54a9e831a8e2e651a465965" }, + "vim-json": { "branch": "master", "commit": "3727f089410e23ae113be6222e8a08dd2613ecf2" }, + "vim-pug": { "branch": "master", "commit": "ea39cd942cf3194230cf72bfb838901a5344d3b3" }, + "vim-ripgrep": { "branch": "master", "commit": "2bb2425387b449a0cd65a54ceb85e123d7a320b8" }, + "vim-svelte-plugin": { "branch": "master", "commit": "612b34640919c29b5cf2d85289dbc762b099858a" }, + "vim-swift": { "branch": "master", "commit": "76dd8b90aec0e934e5a9c524bba9327436d54348" }, + "vim-togglelist": { "branch": "master", "commit": "48f0d30292efdf20edc883e61b121e6123e03df7" }, + "yajs.vim": { "branch": "master", "commit": "2bebc45ce94d02875803c67033b2d294a5375064" }, + "zig.vim": { "branch": "master", "commit": "0c4f965468259ab6e47fd7c6b2127583a8860eb1" } +} \ No newline at end of file diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua new file mode 100644 index 0000000..7c5f488 --- /dev/null +++ b/config/nvim/lua/plugins.lua @@ -0,0 +1,49 @@ +local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require('lazy').setup({ + {'fzf', dir=vim.env.FZF_VIM_PATH}, + + -- Syntaxes + 'https://git.sr.ht/~rbdr/api-notation.vim', + 'elzr/vim-json', + 'othree/yajs.vim', + 'ARM9/snes-syntax-vim', + 'leafgarland/typescript-vim', + 'leafOfTree/vim-svelte-plugin', + 'bumaociyuan/vim-swift', + 'udalov/kotlin-vim', + 'tikhomirov/vim-glsl', + 'jparise/vim-graphql', + 'digitaltoad/vim-pug', + 'https://git.sr.ht/~torresjrjr/gemini.vim', + 'rust-lang/rust.vim', + 'dart-lang/dart-vim-plugin', + 'ziglang/zig.vim', + + -- Editing + 'tpope/vim-endwise', + 'rstacruz/vim-closer', + 'michaeljsmith/vim-indent-object', + + -- Distraction free editing + 'junegunn/goyo.vim', + 'junegunn/limelight.vim', + + -- Tools + {'neoclide/coc.nvim', branch='release'}, + 'vim-scripts/LargeFile', + 'tpope/vim-fugitive', + 'milkypostman/vim-togglelist', + 'jremmen/vim-ripgrep', +})