Browse Source

Convert to lua

master
Taylor Bockman 1 year ago
parent
commit
9f6a1408d7
  1. 36
      README.md
  2. 18
      conf/config.lua
  3. 15
      conf/config.vim
  4. 8
      conf/git.lua
  5. 9
      conf/git.vim
  6. 32
      conf/keybinds.lua
  7. 28
      conf/keybinds.vim
  8. 23
      conf/langs/general.lua
  9. 19
      conf/langs/python.lua
  10. 9
      conf/langs/python.vim
  11. 74
      conf/plugins.lua
  12. 69
      conf/plugins.vim
  13. 22
      conf/search.lua
  14. 15
      conf/search.vim
  15. 12
      conf/ui.lua
  16. 18
      conf/ui.vim
  17. 16
      init.lua
  18. 17
      init.vim
  19. 4
      ui.lua
  20. 5
      ui.vim

36
README.md

@ -7,7 +7,7 @@ it's own repository for easier cloning without pulling down the entire
`essentials` repository. `essentials` repository.
I use the `nord` theme for both my terminal and Vim. You will need to adjust your theme and I use the `nord` theme for both my terminal and Vim. You will need to adjust your theme and
airline according to your tastes in `plugins.vim` and `ui.vim`. airline according to your tastes in `plugins.lua` and `ui.lua`.
The V2 repo aims to take full advantage of asynchronous code and a modularized configuration to make The V2 repo aims to take full advantage of asynchronous code and a modularized configuration to make
adaptation easier and the UI snappier. Additionally support for `tmux` has improved with this iteration adaptation easier and the UI snappier. Additionally support for `tmux` has improved with this iteration
@ -33,12 +33,12 @@ For Python editing:
## Structure ## Structure
* `conf`: Contains all configuration related files. * `conf`: Contains all configuration related files.
* `plugins.vim`: General plugin definitions. * `plugins.lua`: General plugin definitions.
* `keybinds.vim`: General keybinds such as leader key, etc. * `keybinds.lua`: General keybinds such as leader key, etc.
* `config.vim`: Dumping ground for general configurations. * `config.lua`: Dumping ground for general configurations.
* `ui.vim`: General UI configurations. * `ui.lua`: General UI configurations.
* `search.vim`: Search configurations (for example ctrl-p). * `search.lua`: Search configurations (for example ctrl-p).
* `git.vim`: Fugitive configurations. * `git.lua`: Fugitive configurations.
* `langs`: Language specific configurations and keybinds. * `langs`: Language specific configurations and keybinds.
## Installation ## Installation
@ -49,7 +49,7 @@ git clone git@git.xchg.sh:angrygoats/vim-config nvim
``` ```
If you have added/changed plugins remember to `:PlugInstall` after saving. There currently If you have added/changed plugins remember to `:PlugInstall` after saving. There currently
is no autodetect on a changed `plugin.vim`. is no autodetect on a changed `plugins.lua`.
If you run into problems with pyenv on first start, insure that pyenv is installed and your pyenv If you run into problems with pyenv on first start, insure that pyenv is installed and your pyenv
has at least one installation available. For example, run `pyenv install 3.9.1`. has at least one installation available. For example, run `pyenv install 3.9.1`.
@ -70,7 +70,7 @@ order issues. This may be patched in the future.
Pyenv support is added via [vim-pyenv](http://github.com/lambdalisue/vim-pyenv). `:PyenvActivate` can be used to Pyenv support is added via [vim-pyenv](http://github.com/lambdalisue/vim-pyenv). `:PyenvActivate` can be used to
activate a given environment. activate a given environment.
The file `conf/langs/python.vim` contains formatting code typical of a Python project (4 space indents, etc). If you The file `conf/langs/python.lua` contains formatting code typical of a Python project (4 space indents, etc). If you
wish to adjust this you can do that here, or make modifications on a per-project basis. wish to adjust this you can do that here, or make modifications on a per-project basis.
## Other Notes ## Other Notes
@ -104,19 +104,25 @@ The default leader is the space key.
### Git ### Git
`vim-fugitive` is installed. Bindings can be found in `conf/keybinds.vim` and documentation can be found `vim-fugitive` is installed. Bindings can be found in `conf/keybinds.lua` and documentation can be found
[here](https://github.com/tpope/vim-fugitive). [here](https://github.com/tpope/vim-fugitive).
The following binds are set to help development: The following binds are set to help development:
``` ```
nnoremap <Leader>gs :Git<CR> <Leader>gs :Git<CR>
nnoremap <Leader>gd :Git diff<CR> <Leader>gd :Git diff<CR>
nnoremap <Leader>gb :Git blame<CR> <Leader>gb :Git blame<CR>
nnoremap <Leader>gc :Git commit<CR> <Leader>gc :Git commit<CR>
nnoremap <Leader>gp :Git push<CR> <Leader>gp :Git push<CR>
``` ```
### Treesitter
Treesitter is installed as a plugin and syntax highlighting can be modified in `conf/lang/general.lua`.
You can add languages you would like there. Alternatively, auto-loading is enabled which should
handle most syntax highlighting cases.
### LSP ### LSP
`vim-lsp` is installed with `vim-lsp-settings`. While editing a file that has a supported LSP server `vim-lsp` is installed with `vim-lsp-settings`. While editing a file that has a supported LSP server

18
conf/config.lua

@ -0,0 +1,18 @@
-- General Configurations (Any language/Tool)
-- Stripping trailing whitespace on save
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = { "*" },
command = [[:%s/\s\+$//e]]
})
-- Standard variables
vim.opt.expandtab = true -- tabs to spaces
vim.opt.tabstop = 2 -- spaces entered when tab key is pressed
vim.opt.shiftwidth = 2 -- spaces entered for indentation
vim.opt.number = true -- Line numbering
vim.opt.clipboard = "unnamedplus" -- Share system clipboard
vim.opt.eol = true -- End of line at bottom of file
vim.opt.shiftround = true
vim.opt.list = true
vim.opt.listchars={tab = »·, trail=·}

15
conf/config.vim

@ -1,15 +0,0 @@
" General Configurations (Any language/Tool)
" Stripping trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e
" Standard variables
set expandtab " tabs to spaces
set tabstop=2 " spaces entered when tab key is pressed
set shiftwidth=2 " spaces entered for indentation
set number " Line numbering
set clipboard+=unnamedplus " Share system clipboard
set eol " End of line at bottom of file
set shiftround
set list
set list listchars=tab:»·,trail

8
conf/git.lua

@ -0,0 +1,8 @@
-- Fugitive Configuration
--
-- Fugitive bindings
vim.api.nvim_set_keymap('n', '<Leader>gs', ':Git<CR>', {noremap = true})
vim.api.nvim_set_keymap('n', '<Leader>gd', ':Git diff<CR>', {noremap = true})
vim.api.nvim_set_keymap('n', '<Leader>gb', ':Git blame<CR>', {noremap = true})
vim.api.nvim_set_keymap('n', '<Leader>gc', ':Git commit<CR>', {noremap = true})
vim.api.nvim_set_keymap('n', '<Leader>gp', ':Git push<CR>', {noremap = true})

9
conf/git.vim

@ -1,9 +0,0 @@
" Fugitive Configuration
" Fugitive bindings
nnoremap <Leader>gs :Git<CR> " This binding is a weird one.
" :Git<CR> is now the full status page.
nnoremap <Leader>gd :Git diff<CR>
nnoremap <Leader>gb :Git blame<CR>
nnoremap <Leader>gc :Git commit<CR>
nnoremap <Leader>gp :Git push<CR>

32
conf/keybinds.lua

@ -0,0 +1,32 @@
-- General-Purpose keybinds
local keymap_opts = { silent = true, noremap = true }
function NumberToggle()
if vim.o.relativenumber then
vim.opt.relativenumber = false
vim.opt.number = true
else
vim.opt.relativenumber = true
end
end
-- Space is the leader key when outside of insert mode.
vim.g.mapleader = " "
vim.api.nvim_set_keymap('', '<Leader>t', ':NERDTreeToggle<CR>', {silent = true})
-- <SPC>-r controls relative line numbering.
vim.api.nvim_set_keymap('n', '<Leader>r', '<cmd>lua NumberToggle()<CR>', keymap_opts)
-- Pressing enter in command mode clears the current search highlighting until
-- the next search.
vim.api.nvim_set_keymap('n', '<CR>', ':noh<CR><CR>', keymap_opts)
-- This one maps F5 to delete all trailing whitespace
vim.api.nvim_set_keymap(
'n',
'<F5>',
[[:let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>]],
keymap_opts)

28
conf/keybinds.vim

@ -1,28 +0,0 @@
" General-Purpose keybinds
" Space is the leader key when outside of insert mode.
let mapleader=" "
map <silent> <Leader>t :NERDTreeToggle<CR>
nnoremap <silent> <Leader>r :call NumberToggle()<CR>
" Pressing enter in command mode clears the current search highlighting until
" the next search.
nnoremap <silent> <CR> :noh<CR><CR>
" This one maps F5 to delete all trailing whitespace
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" Togglable relative line numbering
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber
set number
else
set relativenumber
endif
endfunc
" <SPC>r will toggle relative line numbers.
nnoremap <silent> <Leader>r :call NumberToggle()<CR>

23
conf/langs/general.vim → conf/langs/general.lua

@ -1,17 +1,17 @@
" General configuration -- General configuration
let g:ale_fixers = { vim.g.ale_linters = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'], python = {'black', 'flake8'},
\ 'python': ['black', 'flake8'], c: {'clang-format'},
\ 'c': ['clang-format'], cpp: {'clang-format'}
\ 'c++': ['clang-format'] }
\}
vim.g.ale_fixers = {
['*'] = {'remove_trailing_lines', 'trim_whitespace'}
}
let g:ale_fix_on_save = 1 let g:ale_fix_on_save = 1
"" Treesitter config. -- Treesitter config.
"" TODO: Remove lua << EOF and EOF when all files are converted
"" to lua.
lua << EOF
require'nvim-treesitter.configs'.setup { require'nvim-treesitter.configs'.setup {
ensure_installed = { ensure_installed = {
"c", "c",
@ -43,4 +43,3 @@ require'nvim-treesitter.configs'.setup {
additional_vim_regex_highlighting = false, additional_vim_regex_highlighting = false,
}, },
} }
EOF

19
conf/langs/python.lua

@ -0,0 +1,19 @@
-- Python configurations
vim.api.nvim_create_autocmd(
{
"BufNewFile",
"BufRead",
},
{
pattern = "*.py",
callback = function()
local buf = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_option(buf, "expandtab")
vim.api.nvim_buf_set_option(buf, "autoindent")
vim.api.nvim_buf_set_option(buf, "tabstop", 4)
vim.api.nvim_buf_set_option(buf, "softtabstop", 4)
vim.api.nvim_buf_set_option(buf, "shiftwidth", 4)
end
}
)

9
conf/langs/python.vim

@ -1,9 +0,0 @@
" Python configurations
"" Set Python standard formatting.
au BufNewFile,BufRead *.py
\ set expandtab |" replace tabs with spaces
\ set autoindent |" copy indent when starting a new line
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4

74
conf/plugins.lua

@ -0,0 +1,74 @@
-- Plugin definitions.
local vim = vim
local Plug = vim.fn['plug#']
-- I have no idea how to auto-install vim-plug on Windows
-- so you will have to install it manually.
vim.cmd [[
if !(has('win16') || has('win32') || has('win64'))
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source %
endif
endif
]]
vim.call('plug#begin', '~/.config/nvim/plugged')
-- UI
Plug 'arcticicestudio/nord-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ryanoasis/vim-devicons'
Plug 'preservim/nerdtree'
-- This plugin has been archived so if there are problems
-- They may emerge here
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug('nvim-treesitter/nvim-treesitter', {['do'] = vim.fn[':TSUpdate']})
-- General Editing
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
-- Search
Plug 'kien/ctrlp.vim'
-- Git
Plug 'tpope/vim-fugitive'
-- LSP
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
-- Autocomplete
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
-- Tmux Helper
Plug 'preservim/vimux'
Plug 'christoomey/vim-tmux-navigator'
-- Linting
Plug 'w0rp/ale'
-- Planning
Plug 'jceb/vim-orgmode'
-- Commands
Plug 'skywind3000/asyncrun.vim'
-- Syntax highlighting
Plug 'sheerun/vim-polyglot'
-- Languages
-------------------------
-- Python
-------------------------
-- Pyenv Support
Plug 'lambdalisue/vim-pyenv'
vim.call('plug#end')

69
conf/plugins.vim

@ -1,69 +0,0 @@
" Plugin definitions.
" I have no idea how to auto-install vim-plug on Windows
" so you will have to install it manually.
if !(has('win16') || has('win32') || has('win64'))
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source %
endif
endif
call plug#begin('~/.config/nvim/plugged')
" UI
Plug 'arcticicestudio/nord-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ryanoasis/vim-devicons'
Plug 'preservim/nerdtree'
"" This plugin has been archived so if there are problems
"" They may emerge here
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" General Editing
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
"" Search
Plug 'kien/ctrlp.vim'
"" Git
Plug 'tpope/vim-fugitive'
"" LSP
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
"" Autocomplete
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
"" Tmux Helper
Plug 'preservim/vimux'
Plug 'christoomey/vim-tmux-navigator'
"" Linting
Plug 'w0rp/ale'
"" Planning
Plug 'jceb/vim-orgmode'
"" Commands
Plug 'skywind3000/asyncrun.vim'
"" Syntax highlighting
Plug 'sheerun/vim-polyglot'
"" Languages
"""""""""""""""""""""""""
" Python
"""""""""""""""""""""""""
"" Pyenv Support
Plug 'lambdalisue/vim-pyenv'
call plug#end()

22
conf/search.lua

@ -0,0 +1,22 @@
-- Specific search configurations
-- ctrlp hotkeys
vim.g.ctrlp_map = '<c-p>'
vim.g.ctrlp_cmd = 'CtrlP'
-- Rebind Ctrl-P to match the window opening keys of nerd tree
vim.g.ctrl_p_prompt_mappings = {
['AcceptSelection("h")'] = {'<c-i>','<c-cr>','<c-s>'},
['AcceptSelection("v")'] = {'<c-s>','<RightMouse>' },
}
-- ctrlp configuration
vim.opt.wildignore = {
"*/tmp/*",
"*.so",
"*.swp",
"*.zip",
"*\\tmp\\*",
"*.exe",
"*.out"
}

15
conf/search.vim

@ -1,15 +0,0 @@
" Specific search configurations
" ctrlp hotkeys
let g:ctrlp_map='<c-p>'
let g:ctrlp_cmd='CtrlP'
" Rebind Ctrl-P to match the window opening keys of nerd tree
let g:ctrl_p_prompt_mappings = {
\ 'AcceptSelection("h")': ['<c-i>', '<c-cr>', '<c-s>'],
\ 'AcceptSelection("v")': ['<c-s>', '<RightMouse>'],
\ }
" ctrlp configuration
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows

12
conf/ui.lua

@ -0,0 +1,12 @@
-- UI Definitions
vim.cmd [[colorscheme nord]]
-- Helps some themes.
vim.opt.termguicolors = true
-- Always show hidden files in nerdtree
vim.g.NERDTreeShowHidden = 1

18
conf/ui.vim

@ -1,18 +0,0 @@
" UI Definitions
colorscheme nord
" Helps some themes.
if (has('nvim'))
let $NVIM_TUI_ENABLE_TRUE_COLOR = 1
endif
if (has('termguicolors'))
set termguicolors
endif
" Always show hidden files in nerdtree
let NERDTreeShowHidden=1

16
init.lua

@ -0,0 +1,16 @@
-- Initialization
require('/conf/plugins')
require('/conf/keybinds')
require('/conf/config')
require('/conf/ui')
require('/conf/search')
require('/conf/git')
require('ui')
local paths = vim.fn.glob(vim.fn.stdpath 'config' .. 'config/langs/*.lua', true, true, true)
for _, file in ipairs(paths) do
require(file)
end

17
init.vim

@ -1,17 +0,0 @@
" Initialization
let g:nvim_config_root = stdpath('config')
exe 'source' g:nvim_config_root . '/conf/plugins.vim'
exe 'source' g:nvim_config_root . '/conf/keybinds.vim'
exe 'source' g:nvim_config_root . '/conf/config.vim'
exe 'source' g:nvim_config_root . '/conf/ui.vim'
exe 'source' g:nvim_config_root . '/conf/search.vim'
exe 'source' g:nvim_config_root . '/conf/git.vim'
let lang_configs = glob(g:nvim_config_root . '/conf/langs/*.vim', 1, 1)
for lang_config in lang_configs
exe 'source' lang_config
endfor

4
ui.lua

@ -0,0 +1,4 @@
-- UI Definitions
vim.cmd [[colorscheme nord]]

5
ui.vim

@ -1,5 +0,0 @@
" UI Definitions
colorscheme nord
Loading…
Cancel
Save