Migrate nvim config to Lua
This commit is contained in:
parent
36f5c77916
commit
9b5c910e22
4
.config/nvim/init.lua
Normal file
4
.config/nvim/init.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
require("config.core")
|
||||||
|
require("config.keymap")
|
||||||
|
require("config.plugins")
|
||||||
|
|
@ -1,119 +0,0 @@
|
|||||||
set breakindent
|
|
||||||
set clipboard=unnamedplus
|
|
||||||
set encoding=utf-8
|
|
||||||
set expandtab
|
|
||||||
set hidden
|
|
||||||
set ignorecase
|
|
||||||
set listchars=tab:▸\ ,eol:¬
|
|
||||||
set nocompatible
|
|
||||||
set nohlsearch
|
|
||||||
set noshowmode
|
|
||||||
set relativenumber
|
|
||||||
set shiftwidth=2
|
|
||||||
set smartcase
|
|
||||||
set smarttab
|
|
||||||
set softtabstop=2
|
|
||||||
set synmaxcol=150
|
|
||||||
set tabstop=4
|
|
||||||
set undofile
|
|
||||||
set wildmenu
|
|
||||||
|
|
||||||
for folder in ['backup', 'swap', 'undo']
|
|
||||||
if !isdirectory($XDG_CACHE_HOME . '/nvim/' . folder)
|
|
||||||
call mkdir($XDG_CACHE_HOME . '/nvim/' . folder, 'p')
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
set backupdir=$XDG_CACHE_HOME/nvim/backup//
|
|
||||||
set directory=$XDG_CACHE_HOME/nvim/swap//
|
|
||||||
set undodir=$XDG_CACHE_HOME/nvim/undo//
|
|
||||||
|
|
||||||
filetype plugin on
|
|
||||||
scriptencoding utf-8
|
|
||||||
syntax on
|
|
||||||
|
|
||||||
" General key mappings
|
|
||||||
map <Up> <Nop>
|
|
||||||
map <Down> <Nop>
|
|
||||||
map <Left> <Nop>
|
|
||||||
map <Right> <Nop>
|
|
||||||
|
|
||||||
no <C-k> <C-w>k
|
|
||||||
no <C-j> <C-w>j
|
|
||||||
no <C-h> <C-w>h
|
|
||||||
no <C-l> <C-w>l
|
|
||||||
|
|
||||||
let mapleader = ","
|
|
||||||
|
|
||||||
" Visually select the text that was last edited/pasted
|
|
||||||
nmap gV `[v`]
|
|
||||||
|
|
||||||
no ; :
|
|
||||||
|
|
||||||
augroup General
|
|
||||||
au!
|
|
||||||
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
|
|
||||||
autocmd bufwritepost init.vim source $MYVIMRC
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
call has('python3')
|
|
||||||
|
|
||||||
if empty(glob($XDG_CONFIG_HOME . '/nvim/autoload/plug.vim'))
|
|
||||||
silent !curl -fLo $XDG_CONFIG_HOME/nvim/autoload/plug.vim --create-dirs
|
|
||||||
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
||||||
|
|
||||||
silent !pip3 install pynvim
|
|
||||||
|
|
||||||
augroup Plug
|
|
||||||
au!
|
|
||||||
autocmd VimEnter * PlugInstall
|
|
||||||
|
|
||||||
" Bubble single lines with vim-unimpaired
|
|
||||||
nmap <C-Up> [e
|
|
||||||
nmap <C-Down> ]e
|
|
||||||
|
|
||||||
" Bubble multiple lines with vim-unimpaired
|
|
||||||
vmap <C-Up> [egv
|
|
||||||
vmap <C-Down> ]egv
|
|
||||||
|
|
||||||
autocmd BufReadPost fugitive://* set bufhidden=delete
|
|
||||||
augroup END
|
|
||||||
endif
|
|
||||||
|
|
||||||
call plug#begin($XDG_DATA_HOME . '/nvim/plugged')
|
|
||||||
|
|
||||||
Plug '/usr/bin/fzf'
|
|
||||||
nnoremap <Leader>p :call fzf#run({ 'sink': 'e' })<CR>
|
|
||||||
|
|
||||||
Plug 'dyng/ctrlsf.vim'
|
|
||||||
Plug 'godlygeek/tabular'
|
|
||||||
Plug 'itchyny/lightline.vim'
|
|
||||||
Plug 'junegunn/goyo.vim'
|
|
||||||
Plug 'junegunn/limelight.vim'
|
|
||||||
let g:limelight_conceal_ctermfg = 'gray'
|
|
||||||
autocmd! User GoyoEnter Limelight
|
|
||||||
autocmd! User GoyoLeave Limelight!
|
|
||||||
|
|
||||||
Plug 'kana/vim-textobj-user'
|
|
||||||
Plug 'markonm/traces.vim'
|
|
||||||
Plug 'mbbill/undotree'
|
|
||||||
nn <silent> <Leader>u :UndotreeToggle <BAR> :UndotreeFocus<CR>
|
|
||||||
|
|
||||||
Plug 'mg979/vim-visual-multi', {'branch': 'master'}
|
|
||||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
|
||||||
Plug 'preservim/nerdtree'
|
|
||||||
nnoremap <leader>n :NERDTreeFocus<CR>
|
|
||||||
|
|
||||||
Plug 'rstacruz/vim-closer'
|
|
||||||
Plug 'sheerun/vim-polyglot'
|
|
||||||
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
|
||||||
Plug 'terryma/vim-expand-region'
|
|
||||||
Plug 'tommcdo/vim-exchange'
|
|
||||||
Plug 'tpope/vim-abolish'
|
|
||||||
Plug 'tpope/vim-commentary'
|
|
||||||
Plug 'tpope/vim-fugitive'
|
|
||||||
Plug 'tpope/vim-repeat'
|
|
||||||
Plug 'tpope/vim-surround'
|
|
||||||
Plug 'tpope/vim-unimpaired'
|
|
||||||
|
|
||||||
call plug#end()
|
|
35
.config/nvim/lua/config/core.lua
Normal file
35
.config/nvim/lua/config/core.lua
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
local o = vim.opt
|
||||||
|
local wo = vim.wo
|
||||||
|
local bo = vim.bo
|
||||||
|
|
||||||
|
-- Global dirs
|
||||||
|
local cachedir = os.getenv("XDG_CACHE_HOME")
|
||||||
|
o.backupdir = cachedir .. "/nvim/backup/"
|
||||||
|
o.directory = cachedir .. "/nvim/swap/"
|
||||||
|
o.undodir = cachedir .. "/nvim/undo/"
|
||||||
|
|
||||||
|
-- Global
|
||||||
|
o.breakindent = true
|
||||||
|
o.clipboard = "unnamedplus"
|
||||||
|
o.compatible = false
|
||||||
|
o.encoding = "utf-8"
|
||||||
|
o.expandtab = true
|
||||||
|
o.hidden = true
|
||||||
|
o.hlsearch = false
|
||||||
|
o.ignorecase = true
|
||||||
|
o.laststatus = 2
|
||||||
|
o.listchars = { eol = '↲', tab = '▸ ', trail = '·' }
|
||||||
|
o.relativenumber = true
|
||||||
|
o.shiftwidth = 2
|
||||||
|
o.showmode = false
|
||||||
|
o.smartcase = true
|
||||||
|
o.smarttab = true
|
||||||
|
o.softtabstop = 2
|
||||||
|
o.synmaxcol = 150
|
||||||
|
o.tabstop = 4
|
||||||
|
o.undofile = true
|
||||||
|
o.wildmenu = true
|
||||||
|
|
||||||
|
-- Window
|
||||||
|
|
||||||
|
-- Buffer
|
35
.config/nvim/lua/config/keymap.lua
Normal file
35
.config/nvim/lua/config/keymap.lua
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
local keymap = vim.keymap.set
|
||||||
|
local opts = { silent = true }
|
||||||
|
|
||||||
|
vim.g.mapleader = ","
|
||||||
|
|
||||||
|
-- Modes
|
||||||
|
-- Normal = "n",
|
||||||
|
-- Insert = "i",
|
||||||
|
-- Visual = "v",
|
||||||
|
-- Visual Block = "x",
|
||||||
|
-- Term = "t",
|
||||||
|
-- Command = "c"
|
||||||
|
|
||||||
|
keymap("n", "<Left>", "<Nop>", opts)
|
||||||
|
keymap("n", "<Right>", "<Nop>", opts)
|
||||||
|
keymap("n", "<Up>", "<Nop>", opts)
|
||||||
|
keymap("n", "<Down>", "<Nop>", opts)
|
||||||
|
|
||||||
|
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", "gV", "`[v`]", opts)
|
||||||
|
|
||||||
|
keymap("n", ";", ":", { noremap = true })
|
||||||
|
|
||||||
|
-- Bubble single lines with vim-unimpaired
|
||||||
|
keymap("n", "<C-Up>", "[e", opts)
|
||||||
|
keymap("n", "<C-Down>", "]e", opts)
|
||||||
|
|
||||||
|
-- Bubble multiple lines with vim-unimpaired
|
||||||
|
keymap("v", "<C-Up>", "[egv", opts)
|
||||||
|
keymap("v", "<C-Down>", "]egv", opts)
|
||||||
|
|
80
.config/nvim/lua/config/plugins.lua
Normal file
80
.config/nvim/lua/config/plugins.lua
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
local fn = vim.fn
|
||||||
|
|
||||||
|
local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim"
|
||||||
|
if fn.empty(fn.glob(install_path)) > 0 then
|
||||||
|
PACKER_BOOTSTRAP = fn.system {
|
||||||
|
"git",
|
||||||
|
"clone",
|
||||||
|
"--depth",
|
||||||
|
"1",
|
||||||
|
"https://github.com/wbthomason/packer.nvim",
|
||||||
|
install_path,
|
||||||
|
}
|
||||||
|
print "Installing packer close and reopen Neovim..."
|
||||||
|
vim.cmd [[packadd packer.nvim]]
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd [[
|
||||||
|
augroup packer_user_config
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWritePost plugins.lua source <afile> | PackerSync
|
||||||
|
augroup end
|
||||||
|
]]
|
||||||
|
|
||||||
|
local status_ok, packer = pcall(require, "packer")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
packer.init {
|
||||||
|
display = {
|
||||||
|
open_fn = function()
|
||||||
|
return require("packer.util").float { border = "rounded" }
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return packer.startup(function(use)
|
||||||
|
-- Utilities
|
||||||
|
use { "wbthomason/packer.nvim", opt = true }
|
||||||
|
use { "mbbill/undotree" }
|
||||||
|
use { "nvim-lua/plenary.nvim" }
|
||||||
|
use { "nvim-telescope/telescope.nvim" }
|
||||||
|
use {
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
event = "BufEnter",
|
||||||
|
run = ":TSUpdate",
|
||||||
|
config = [[require('config.treesitter')]]
|
||||||
|
}
|
||||||
|
use { "tpope/vim-fugitive", event = "User InGitRepo" }
|
||||||
|
|
||||||
|
-- Editing
|
||||||
|
use { "godlygeek/tabular" }
|
||||||
|
use { "kana/vim-textobj-user" }
|
||||||
|
use { "mg979/vim-visual-multi", branch = "master" }
|
||||||
|
use { "terryma/vim-expand-region" }
|
||||||
|
use { "tommcdo/vim-exchange", event = "VimEnter" }
|
||||||
|
use { "tpope/vim-abolish" }
|
||||||
|
use { "tpope/vim-commentary", event = "VimEnter" }
|
||||||
|
use { "tpope/vim-repeat", event = "VimEnter" }
|
||||||
|
use { "tpope/vim-surround", event = "VimEnter" }
|
||||||
|
use { "windwp/nvim-autopairs" }
|
||||||
|
|
||||||
|
-- UI
|
||||||
|
use { "junegunn/goyo.vim" }
|
||||||
|
use { "junegunn/limelight.vim" }
|
||||||
|
use { "markonm/traces.vim" }
|
||||||
|
|
||||||
|
-- Searching
|
||||||
|
use { "dyng/ctrlsf.vim" }
|
||||||
|
|
||||||
|
-- LSP
|
||||||
|
use { "neovim/nvim-lspconfig" }
|
||||||
|
use { "williamboman/nvim-lsp-installer" }
|
||||||
|
use { "jose-elias-alvarez/null-ls.nvim" }
|
||||||
|
|
||||||
|
if PACKER_BOOTSTRAP then
|
||||||
|
require("packer").sync()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
51
.config/nvim/lua/config/treesitter.lua
Normal file
51
.config/nvim/lua/config/treesitter.lua
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
require("nvim-treesitter.configs").setup({
|
||||||
|
ensure_installed = {
|
||||||
|
"bash",
|
||||||
|
"c",
|
||||||
|
"cmake",
|
||||||
|
"cpp",
|
||||||
|
"css",
|
||||||
|
"dockerfile",
|
||||||
|
"glsl",
|
||||||
|
"graphql",
|
||||||
|
"haskell",
|
||||||
|
"http",
|
||||||
|
"html",
|
||||||
|
"java",
|
||||||
|
"javascript",
|
||||||
|
"jsdoc",
|
||||||
|
"json",
|
||||||
|
"json5",
|
||||||
|
"latex",
|
||||||
|
"lua",
|
||||||
|
"markdown",
|
||||||
|
"ninja",
|
||||||
|
"nix",
|
||||||
|
"org",
|
||||||
|
"perl",
|
||||||
|
"php",
|
||||||
|
"pug",
|
||||||
|
"python",
|
||||||
|
"regex",
|
||||||
|
"rst",
|
||||||
|
"ruby",
|
||||||
|
"rust",
|
||||||
|
"scala",
|
||||||
|
"scss",
|
||||||
|
"toml",
|
||||||
|
"tsx",
|
||||||
|
"typescript",
|
||||||
|
"vim",
|
||||||
|
"yaml",
|
||||||
|
"zig"
|
||||||
|
},
|
||||||
|
ignore_install = {},
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
disable = {},
|
||||||
|
},
|
||||||
|
indent = {
|
||||||
|
enable = true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,5 +3,6 @@
|
|||||||
.config/configstore
|
.config/configstore
|
||||||
.config/dconf
|
.config/dconf
|
||||||
.config/nvim/autoload/
|
.config/nvim/autoload/
|
||||||
|
.config/nvim/plugin/
|
||||||
.config/pulse/
|
.config/pulse/
|
||||||
.config/zsh/.zcompdump
|
.config/zsh/.zcompdump
|
||||||
|
Reference in New Issue
Block a user