Refactor .vimrc into config.vim and support nvim only

This commit is contained in:
mitchell 2024-07-02 19:38:01 -04:00
parent 8be2f42aba
commit a2b223784f
5 changed files with 159 additions and 216 deletions

114
.config/nvim/config.vim Normal file
View File

@ -0,0 +1,114 @@
set colorcolumn=100
set cursorline
set showmatch
set hlsearch
set mouse=a
set mousemodel=extend
set number
set noshowmode
set background=dark
set nowrap
set tabstop=2
set shiftwidth=0
set expandtab
set textwidth=100
set cmdheight=2
set ignorecase
set smartcase
set shortmess+=c
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
set nofoldenable " Disable folding at startup.
inoremap jj <Esc>
let mapleader = ','
nnoremap <leader>f <cmd>ALEFix<cr>
nnoremap <leader>a <cmd>ALEToggle<cr>
nnoremap <leader>n <cmd>Neotree<cr>
nnoremap <leader>t <cmd>Telescope<cr>
nnoremap <leader>p <cmd>Telescope git_files<cr>
nnoremap <C-p> <cmd>Telescope find_files<cr>
nnoremap <leader>s <cmd>Telescope treesitter<cr>
nnoremap <leader>ga <cmd>Telescope grep_string<cr>
nnoremap <leader>gg <cmd>Telescope lsp_definitions<cr>
nnoremap <leader>gr <cmd>Telescope lsp_references<cr>
nnoremap <leader>gi <cmd>Telescope lsp_implementations<cr>
nnoremap <leader>gd <cmd>Telescope lsp_type_definitions<cr>
nnoremap <leader>o <cmd>SymbolsOutline<cr>
nnoremap <leader>z <cmd>ZenMode<cr>
nnoremap <leader>l <cmd>Twilight<cr>
nnoremap <leader>c <cmd>COQnow<cr>
tnoremap <Esc> <C-\><C-n>
" Allows you to use // in order to search for the visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
colorscheme gruvbox
let g:neovide_scale_factor = 0.7
let g:ale_linters_explicit = 1
let g:ale_completion_enabled = 0
let g:pencil#map#suspend_af = 'K'
let g:lightline = {
\ 'colorscheme': 'wombat',
\ }
let g:ale_linters = {
\ 'javascript': ['eslint', 'stylelint'],
\ 'typescript': ['eslint', 'stylelint'],
\ 'javascriptreact': ['eslint', 'stylelint'],
\ 'typescriptreact': ['eslint', 'stylelint'],
\ 'go': ['golint', 'go vet'],
\ 'vue': ['eslint', 'stylelint'],
\ 'make': ['checkmake'],
\ 'proto': ['protoc-gen-lint'],
\ 'dockerfile': ['hadolint'],
\ 'dart': ['dartanalyzer'],
\ 'fish': ['fish'],
\ 'vim': ['vint'],
\ 'elixir': ['credo'],
\ 'cs': ['OmniSharp'],
\ 'terraform': ['tflint'],
\ 'ruby': ['rubocop'],
\ 'css': ['stylelint'],
\ 'sh': ['shellcheck'],
\ 'python': ['pylint'],
\ }
let g:ale_fixers = {
\ 'go': ['goimports', 'remove_trailing_lines', 'trim_whitespace'],
\ 'graphql': ['prettier'],
\ 'javascript': ['prettier'],
\ 'typescript': ['prettier'],
\ 'javascriptreact': ['prettier'],
\ 'typescriptreact': ['prettier'],
\ 'vue': ['prettier'],
\ 'css': ['prettier'],
\ 'yaml': ['prettier'],
\ 'json': ['prettier'],
\ 'dart': ['dartfmt'],
\ 'html': ['prettier'],
\ 'markdown': ['prettier'],
\ 'make': ['remove_trailing_lines', 'trim_whitespace'],
\ 'elixir': ['mix_format'],
\ 'terraform': ['terraform'],
\ 'ruby': ['rubocop'],
\ 'python': ['black'],
\ 'lua': ['stylua'],
\ }
augroup ft_fish
au!
autocmd FileType fish set tabstop=4
augroup END
augroup term
au!
autocmd TermOpen * set nonumber
augroup END

View File

@ -1,22 +1,53 @@
vim.cmd("set runtimepath^=~/.vim runtimepath+=~/.vim/after") local plug = vim.fn["plug#"]
vim.cmd("let &packpath = &runtimepath") vim.call("plug#begin")
vim.cmd("source ~/.vimrc")
vim.g.coq_settings = { auto_start = true } -- Contains lots of sensible configurations, which I have in turn omitted from here
plug("tpope/vim-sensible")
plug("tpope/vim-eunuch")
plug("tpope/vim-surround")
plug("tpope/vim-endwise")
plug("itchyny/lightline.vim")
plug("edkolev/tmuxline.vim")
plug("airblade/vim-gitgutter")
plug("reedes/vim-pencil", { ["on"] = { "HardPencil", "SoftPencil" } })
plug("w0rp/ale")
plug("tpope/vim-fugitive", { ["on"] = { "G", "Git" }, ["for"] = "gitcommit" })
plug("mileszs/ack.vim", { ["on"] = "Ack" })
plug("nvim-treesitter/nvim-treesitter", { ["do"] = ":TSUpdate" })
plug("nvim-treesitter/nvim-treesitter-context")
plug("BurntSushi/ripgrep")
plug("MunifTanjim/nui.nvim")
plug("rcarriga/nvim-notify")
plug("nvim-lua/plenary.nvim")
plug("nvim-tree/nvim-web-devicons")
plug("ms-jpq/coq_nvim")
plug("folke/noice.nvim")
plug("ggandor/leap.nvim")
plug("folke/zen-mode.nvim")
plug("folke/twilight.nvim")
plug("neovim/nvim-lspconfig")
plug("ellisonleao/gruvbox.nvim")
plug("nvim-neo-tree/neo-tree.nvim")
plug("nvim-telescope/telescope.nvim")
plug("simrat39/symbols-outline.nvim")
plug("nvim-telescope/telescope-fzf-native.nvim", {
["do"] = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build",
})
plug("pmizio/typescript-tools.nvim")
vim.call("plug#end")
vim.g.neovide_scale_factor = 0.7
vim.opt.guifont = { "JetBrainsMono Nerd Font", "h13" } vim.opt.guifont = { "JetBrainsMono Nerd Font", "h13" }
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>") vim.g.coq_settings = { auto_start = true }
vim.api.nvim_create_autocmd("TermOpen", {
pattern = "*",
command = "set nonumber",
})
require("gruvbox").setup({ require("gruvbox").setup({
transparent_mode = true, transparent_mode = true,
}) })
vim.cmd("colorscheme gruvbox")
require("twilight").setup() require("twilight").setup()
require("zen-mode").setup({ require("zen-mode").setup({
@ -165,3 +196,5 @@ for _, lsp in ipairs(servers) do
flags = lsp_flags, flags = lsp_flags,
})) }))
end end
vim.cmd("source ~/.config/nvim/config.vim")

202
.vimrc
View File

@ -1,202 +0,0 @@
call plug#begin('~/.vim/plugged')
" Contains lots of sensible configurations, which I have in turn omitted from this file
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-endwise'
Plug 'itchyny/lightline.vim'
Plug 'edkolev/tmuxline.vim'
Plug 'airblade/vim-gitgutter'
Plug 'reedes/vim-pencil', { 'on': ['HardPencil', 'SoftPencil'] }
if !exists('g:vscode')
Plug 'w0rp/ale'
Plug 'tpope/vim-fugitive', { 'on': ['G', 'Git'], 'for': 'gitcommit' }
Plug 'mileszs/ack.vim', { 'on': 'Ack' }
if has('nvim')
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/nvim-treesitter-context'
Plug 'BurntSushi/ripgrep'
Plug 'MunifTanjim/nui.nvim'
Plug 'rcarriga/nvim-notify'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-tree/nvim-web-devicons'
Plug 'ms-jpq/coq_nvim'
Plug 'folke/noice.nvim'
Plug 'ggandor/leap.nvim'
Plug 'folke/zen-mode.nvim'
Plug 'folke/twilight.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'ellisonleao/gruvbox.nvim'
Plug 'nvim-neo-tree/neo-tree.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'simrat39/symbols-outline.nvim'
Plug 'nvim-telescope/telescope-fzf-native.nvim', {
\ 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build'
\ }
Plug 'pmizio/typescript-tools.nvim'
else
Plug 'morhetz/gruvbox'
Plug 'junegunn/fzf'
Plug 'mcchrish/nnn.vim'
" Language specific plugins
Plug 'dart-lang/dart-vim-plugin'
Plug 'elixir-editors/vim-elixir'
Plug 'georgewitteman/vim-fish'
Plug 'fatih/vim-go'
Plug 'jparise/vim-graphql'
Plug 'pangloss/vim-javascript'
Plug 'vim-ruby/vim-ruby'
Plug 'cespare/vim-toml'
Plug 'OmniSharp/omnisharp-vim'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'b4b4r07/vim-hcl'
Plug 'hashivim/vim-terraform'
Plug 'PProvost/vim-ps1'
Plug 'vmchale/dhall-vim'
Plug 'baskerville/vim-sxhkdrc'
Plug 'keith/swift.vim'
endif
endif
call plug#end()
set colorcolumn=100
set cursorline
set showmatch
set hlsearch
set mouse=a
set mousemodel=extend
set number
set noshowmode
set background=dark
set nowrap
set tabstop=2
set shiftwidth=0
set expandtab
set textwidth=100
set cmdheight=2
set ignorecase
set smartcase
set shortmess+=c
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
set nofoldenable " Disable folding at startup.
let mapleader = 'j'
inoremap <leader>j <Esc>
let mapleader = ','
nnoremap <leader>f <cmd>ALEFix<cr>
nnoremap <leader>a <cmd>ALEToggle<cr>
if has('nvim')
nnoremap <leader>n <cmd>Neotree<cr>
nnoremap <leader>t <cmd>Telescope<cr>
nnoremap <leader>p <cmd>Telescope git_files<cr>
nnoremap <C-p> <cmd>Telescope find_files<cr>
nnoremap <leader>s <cmd>Telescope treesitter<cr>
nnoremap <leader>ga <cmd>Telescope grep_string<cr>
nnoremap <leader>gg <cmd>Telescope lsp_definitions<cr>
nnoremap <leader>gr <cmd>Telescope lsp_references<cr>
nnoremap <leader>gi <cmd>Telescope lsp_implementations<cr>
nnoremap <leader>gd <cmd>Telescope lsp_type_definitions<cr>
nnoremap <leader>o <cmd>SymbolsOutline<cr>
nnoremap <leader>z <cmd>ZenMode<cr>
nnoremap <leader>l <cmd>Twilight<cr>
nnoremap <leader>c <cmd>COQnow<cr>
else
nnoremap <leader>n <cmd>NnnPicker<cr>
nnoremap <leader>p <cmd>FZF<cr>
nnoremap <leader>a <cmd>Ack<cr>
endif
" Allows you to use // in order to search for the visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
let g:gruvbox_italic=1
colorscheme gruvbox
highlight Normal ctermbg=None
let g:ackprg = 'ag --nogroup --nocolor --column --hidden'
let g:lightline = {
\ 'colorscheme': 'wombat',
\ }
let g:ale_linters = {
\ 'javascript': ['eslint', 'stylelint'],
\ 'typescript': ['eslint', 'stylelint'],
\ 'javascriptreact': ['eslint', 'stylelint'],
\ 'typescriptreact': ['eslint', 'stylelint'],
\ 'go': ['golint', 'go vet'],
\ 'vue': ['eslint', 'stylelint'],
\ 'make': ['checkmake'],
\ 'proto': ['protoc-gen-lint'],
\ 'dockerfile': ['hadolint'],
\ 'dart': ['dartanalyzer'],
\ 'fish': ['fish'],
\ 'vim': ['vint'],
\ 'elixir': ['credo'],
\ 'cs': ['OmniSharp'],
\ 'terraform': ['tflint'],
\ 'ruby': ['rubocop'],
\ 'css': ['stylelint'],
\ 'sh': ['shellcheck'],
\ 'python': ['pylint'],
\ }
let g:ale_fixers = {
\ 'go': ['goimports', 'remove_trailing_lines', 'trim_whitespace'],
\ 'graphql': ['prettier'],
\ 'javascript': ['prettier'],
\ 'typescript': ['prettier'],
\ 'javascriptreact': ['prettier'],
\ 'typescriptreact': ['prettier'],
\ 'vue': ['prettier'],
\ 'css': ['prettier'],
\ 'yaml': ['prettier'],
\ 'json': ['prettier'],
\ 'dart': ['dartfmt'],
\ 'html': ['prettier'],
\ 'markdown': ['prettier'],
\ 'make': ['remove_trailing_lines', 'trim_whitespace'],
\ 'elixir': ['mix_format'],
\ 'terraform': ['terraform'],
\ 'ruby': ['rubocop'],
\ 'python': ['black'],
\ 'lua': ['stylua'],
\ }
let g:ale_linters_explicit = 1
let g:ale_completion_enabled = 0
let g:OmniSharp_server_stdio = 1
let g:pencil#map#suspend_af = 'K'
let g:nnn#layout = {'left': '~20%'}
let g:nnn#command = 'nnn -eHo'
augroup ft_fish
au!
autocmd FileType fish set tabstop=4
augroup END
augroup ft_cs
au!
autocmd FileType cs nmap <leader>g <Plug>(omnisharp_go_to_definition)
autocmd FileType cs nmap <leader>r <Plug>(omnisharp_find_usages)
autocmd FileType cs nmap <leader>h <Plug>(omnisharp_preview_definition)
autocmd FileType cs nmap <leader>c <Plug>(omnisharp_code_actions)
augroup END

4
sync
View File

@ -59,17 +59,15 @@ function sync_terminal_env
rsync -aP ./.config/fish ~/.config/ rsync -aP ./.config/fish ~/.config/
and rsync -aP ./.config/nvim ~/.config/ and rsync -aP ./.config/nvim ~/.config/
and rsync -aP ./.local/share/nvim ~/.local/share/
and rsync -aP ./.tmux-line.conf ~/ and rsync -aP ./.tmux-line.conf ~/
and rsync -aP ./.tmux.conf ~/ and rsync -aP ./.tmux.conf ~/
and rsync -aP ./.vim ~/
and rsync -aP ./.vimrc ~/
and rsync -aP ./scripts/ ~/code/scripts/ and rsync -aP ./scripts/ ~/code/scripts/
and rsync -aP ./.config/starship.toml ~/.config/ and rsync -aP ./.config/starship.toml ~/.config/
end end
function sync_desktop_env -a uname function sync_desktop_env -a uname
rsync -aP ./.wezterm.lua ~/ rsync -aP ./.wezterm.lua ~/
and rsync -aP ./.ideavimrc ~/
or return 1 or return 1
switch $uname switch $uname