Browse Source

hoo boy

main
Cian Butler 1 month ago
parent
commit
7398b34e17
Signed by: butlerx GPG Key ID: B37CA765BAA89170
15 changed files with 468 additions and 475 deletions
  1. +0
    -21
      config/nvim/autoload/functions.vim
  2. +9
    -9
      config/nvim/ftplugin/apache.vim
  3. +9
    -0
      config/nvim/ftplugin/go.lua
  4. +0
    -9
      config/nvim/ftplugin/go.vim
  5. +1
    -1
      config/nvim/indent/html.lua
  6. +129
    -176
      config/nvim/init.lua
  7. +9
    -10
      config/nvim/lua/hipster.lua
  8. +65
    -43
      config/nvim/lua/plugins.lua
  9. +32
    -14
      config/nvim/lua/utils.lua
  10. +55
    -54
      config/nvim/plugin/ale.lua
  11. +74
    -69
      config/nvim/plugin/lsp.lua
  12. +57
    -0
      config/nvim/plugin/nerdtree.lua
  13. +0
    -47
      config/nvim/plugin/nerdtree.vim
  14. +22
    -22
      config/nvim/plugin/startify.lua
  15. +6
    -0
      config/nvim/stylua.toml

+ 0
- 21
config/nvim/autoload/functions.vim View File

@@ -1,21 +0,0 @@
" load vim-plug if it does not exist in the dotfiles
let s:plugpath = '~/.local/share/nvim/site/autoload/plug.vim'
function! functions#PlugLoad()
if empty(glob(s:plugpath))
if executable('curl')
echom "Installing vim-plug at " . s:plugpath
let plugurl = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
call system('curl -fLo ' . shellescape(s:plugpath) . ' --create-dirs ' . plugurl)
if v:shell_error
echom "Error downloading vim-plug. Please install it manually.\n"
exit
endif
augroup Plugins
au!
au VimEnter * PlugInstall | source $MYVIMRC
else
echom "vim-plug not installed. Please install it manually or install curl.\n"
exit
endif
endif
endfunction

+ 9
- 9
config/nvim/ftplugin/apache.vim View File

@@ -1,11 +1,11 @@
" Language: apache
" Maintainer: Satya P <vim@thesatya.com>
" Last Change: Sat, 27 Jan 2007 11:24:59 EST
" Notes: 0) Copied from Johannes Zellner <johannes@zellner.org>'s xml
" Language: apache
" Maintainer: Satya P <vim@thesatya.com>
" Last Change: Sat, 27 Jan 2007 11:24:59 EST
" Notes: 0) Copied from Johannes Zellner <johannes@zellner.org>'s xml
" indent script

" Only load this indent file when no other was loaded.
if exists("b:did_indent")
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
@@ -14,7 +14,7 @@ let b:did_indent = 1
setlocal indentexpr=ApacheIndentGet(v:lnum,1)
setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,}

set cpo-=C
set cpotions-=C

" [-- finish, if the function already exists --]
if exists('*ApacheIndentGet') | finish | endif
@@ -25,7 +25,7 @@ fun! ApacheIndentGet(lnum, use_syntax_check)

" Hit the start of the file, use zero indent.
if lnum == 0
return 0
return 0
endif

let prevline=getline(lnum)
@@ -34,10 +34,10 @@ fun! ApacheIndentGet(lnum, use_syntax_check)
let inddelta=0
if match(line, '^\s*</') == 0
"if this is a closing tag line, reduce its indentation
let inddelta = 0 - &sw
let inddelta = 0 - &shiftwidth
elseif match(prevline,'^\s*<\a') == 0
"if previous line is a opening tag line, increase its indentation
let inddelta = &sw
let inddelta = &shiftwidth
endif

let ind = ind + inddelta


+ 9
- 0
config/nvim/ftplugin/go.lua View File

@@ -0,0 +1,9 @@
vim.g.go_fmt_autosave = 0
vim.g.go_imports_autosave = 0
vim.g.go_metalinter_autosave = 0
vim.g.go_fmt_command = "gopls"
vim.g.go_metalinter_command = "golangci-lint"
vim.g.go_gopls_gofumpt = 1
vim.g.go_highlight_function_calls = 1
vim.g.go_highlight_fields = 1
vim.g.go_highlight_types = 1

+ 0
- 9
config/nvim/ftplugin/go.vim View File

@@ -1,9 +0,0 @@
let g:go_fmt_autosave = 0
let g:go_imports_autosave = 0
let g:go_metalinter_autosave_= 0
let g:go_fmt_command='gopls'
let g:go_metalinter_command = 'golangci-lint'
let g:go_gopls_gofumpt=1
let g:go_highlight_function_calls = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1

+ 1
- 1
config/nvim/indent/html.lua View File

@@ -1,2 +1,2 @@
-- Indent after <p> paragraph tags too
vim.g.html_indent_inctags = 'p'
vim.g.html_indent_inctags = "p"

+ 129
- 176
config/nvim/init.lua View File

@@ -1,225 +1,166 @@
local utils = require("utils")
local utils = require "utils"
local set = vim.opt
local fn = vim.fn
local map = utils.map

vim.cmd [[runtime system.vim]]
require('plugins')
require "plugins"

if vim.api.nvim_eval("has('autocmd')") then
-- Set leader to space
vim.g.mapleader = " "
vim.cmd [[filetype plugin indent on]]
if fn.has "autocmd" then
-- Set leader to space
vim.g.mapleader = " "
vim.cmd [[filetype plugin indent on]]
end
if vim.api.nvim_eval("has('syntax')") then
-- Use syntax highlighting
if not vim.g.syntax_on then
vim.cmd [[syntax enable]]
end
-- Use my colorscheme if using the GUI or if we have 256 colors
if vim.api.nvim_eval("has('gui_running') || &t_Co >= 256") then
vim.cmd [[silent! color monokai]]
end
-- If not monokai, then default with dark background
if not vim.g.colors_name then
vim.o.background = "dark"
end
if fn.has "syntax" then
-- Use syntax highlighting
if not vim.g.syntax_on then
vim.cmd [[syntax enable]]
end
-- Use my colorscheme if using the GUI or if we have 256 colors
if vim.api.nvim_eval "&t_Co >= 256" then
vim.cmd [[color monokai]]
end
-- If not monokai, then default with dark background
if not vim.g.colors_name then
vim.o.background = "dark"
end
end

-- Use UTF-8 if we can and env LANG didn't tell us not to
if vim.api.nvim_eval("has('multi_byte') && !exists('$LANG') && &encoding ==# 'latin1'") then
set.encoding = "utf-8"
if fn.has "multi_byte" and not fn.exists "$LANG" and vim.api.nvim_eval "&encoding" == "latin1" then
set.encoding = "utf-8"
end

-- The all-important default indent settings; filetypes to tweak
set.autoindent = true -- Use indent of previous line on new lines
set.expandtab = true -- Use spaces instead of tabs
set.shiftwidth = 2 -- Indent with two spaces
set.softtabstop = 2 -- Insert two spaces with tab key
set.smartindent = true -- Enable smart-indent
set.smarttab = true -- Enable smart-tabs
set.autoindent = true -- Use indent of previous line on new lines
set.expandtab = true -- Use spaces instead of tabs
set.shiftwidth = 2 -- Indent with two spaces
set.softtabstop = 2 -- Insert two spaces with tab key
set.smartindent = true -- Enable smart-indent
set.smarttab = true -- Enable smart-tabs
set.tabstop = 2
set.cindent = true
set.backspace = { "indent", "eol", "start" } -- Let me backspace over pretty much anything
set.clipboard = { "unnamed", "unnamedplus" } -- use the system clipboard
set.breakindent = true -- Indent wrapped lines
set.confirm = true -- Give me a prompt instead of just rejecting risky :write, :saveas
set.comments = "" -- Clear default 'comments' value, let the filetype handle it

-- Add completion options
set.completeopt:append {
"noinsert",
"longest", -- Insert longest common substring
"menuone", -- Show the menu even if only one match
"noselect", -- Show the menu even if only one match
}

-- Fold based on indent, but only when I ask
if fn.has "folding" then
set.foldlevelstart = 99
set.foldenable = false
set.foldcolumn = "1"
set.foldlevel = 0
set.foldmethod = "expr"
set.foldexpr = "nvim_treesitter#foldexpr()"
end

set.backspace = "indent,eol,start"
set.breakindent = true
-- Delete comment leaders when joining lines, if supported
set.formatoptions:append { "j" }

set.confirm = true
-- If available, use GNU grep niceties for searching
if fn.system "grep --version" ~= "^grep (GNU grep)" then
set.grepprg = "grep -HnRs --exclude='.git*'"
end

set.comments = ""
-- Allow buffers to have changes without being displayed
set.hidden = true

vim.cmd [[
" Add completion options
if exists('+completeopt')
set completeopt+=noinsert
set completeopt+=longest " Insert longest common substring
set completeopt+=menuone " Show the menu even if only one match
set completeopt+=noselect " Show the menu even if only one match
else
set completeopt=noinsert,longest,menuone,noselect
endif

" Don't wait for a key after Escape in insert mode
" In vim-tiny but not NeoVim, so just suppress errors
silent! set noesckeys

" Fold based on indent, but only when I ask
if has('folding')
set foldlevelstart=99
set foldmethod=indent
endif

" Delete comment leaders when joining lines, if supported
silent! set formatoptions+=j

" If available, use GNU grep niceties for searching
if system('grep --version') =~# '^grep (GNU grep)'
set grepprg=grep\ -HnRs\ --exclude='.git*'
endif

" Don't load GUI menus; set here before GUI starts
if has('gui_running')
set guioptions+=M
set guioptions+=LlRrb
set guioptions-=LlRrb
set guioptions-=T
set guioptions-=m
endif

" Allow buffers to have changes without being displayed
set hidden

" Keep much more command and search history
set history=2000

" Highlight completed searches; clear on reload
set hlsearch
if 1
nohlsearch
endif
]]
set.include=""
-- Keep much more command and search history
set.history = 2000

-- Highlight completed searches; clear on reload
vim.cmd [[
" Show search matches as I type my pattern
set incsearch

" Don't join lines with two spaces at the end of sentences
set nojoinspaces

" Don't show a statusline if there's only one window
" This is the Vim default, but NeoVim changed it
if &laststatus != 1
set laststatus=1
endif

" Don't redraw the screen during batch execution
set lazyredraw

" Break lines at word boundaries
set linebreak

" Disable command line display of file position
" This is the Vim default, but NeoVim changed it
if &ruler
set noruler
endif

" Show row and column ruler information
set ruler
set colorcolumn=100

" Options for file search with gf/:find
set path-=/usr/include " Let the C/C++ filetypes set that
set path+=** " Search current directory's whole tree

" Prefix wrapped rows with three dots
set showbreak=...

" New windows go below or to the right of a split
set splitbelow
set splitright

" Give me a bit longer to complete mappings
set notimeout
set nottimeout
set timeoutlen=10000
set ttimeoutlen=10000

" No terminal mouse, even if we could
silent! set ttymouse=

" Keep undo files, hopefully in a dedicated directory
if has('persistent_undo')
set undofile
set undodir^=~/.vim/cache/undo//
endif
set undolevels=1000 " Number of undo levels

" Wildmenu settings; see also plugin/wildignore.vim
set wildmenu " Use wildmenu
"set wildmode=list:longest " Tab press completes and lists
silent! set wildignorecase " Case insensitive, if supported

" Let me move beyond buffer text in visual block mode
if exists('+virtualedit')
set virtualedit+=block
endif
set hlsearch
if 1
nohlsearch
endif
]]

set.include = "" -- Don't assume I'm editing C; let the filetype set this
set.incsearch = true -- Show search matches as I type my pattern
set.joinspaces = false -- Don't join lines with two spaces at the end of sentences
set.lazyredraw = true -- Don't redraw the screen during batch execution
set.linebreak = true -- Break lines at word boundaries

-- Show row and column ruler information
set.ruler = true
set.colorcolumn = "100"

-- Options for file search with gf/:find
set.path:remove { "/usr/include" } -- Let the C/C++ filetypes set that
set.path:append { "**" } -- Search current directory's whole tree

-- Prefix wrapped rows with three dots
set.showbreak = "..."

-- New windows go below or to the right of a split
set.splitbelow = true
set.splitright = true

-- Give me a bit longer to complete mappings
set.timeout = false
set.ttimeout = false
set.timeoutlen = 10000
set.ttimeoutlen = 10000

-- Keep undo files, hopefully in a dedicated directory
if fn.has "persistent_undo" then
set.undofile = true
set.undodir:append { "~/.vim/cache/undo//" }
end

-- Number of undo levels
set.undolevels = 1000

-- Wildmenu settings; see also plugin/wildignore.vim
set.wildmenu = true -- Use wildmenu
set.wildignorecase = true -- Case insensitive, if supported

-- Let me move beyond buffer text in visual block mode
if fn.exists "+virtualedit" then
set.virtualedit:append { "block" }
end

set.diffopt = "filler,iwhite"
set.fileencoding="utf-8"
set.fileencoding = "utf-8"
vim.cmd [[set fillchars+=stl:\ ,stlnc:\ ]]
set.foldcolumn = "1"
set.foldlevel = 0
set.foldmethod = "expr"
set.foldexpr = "nvim_treesitter#foldexpr()"
set.ignorecase = true
set.ignorecase = true -- Always case-insensitive
set.laststatus = 2
set.linebreak = true
vim.cmd [[
set list lcs=tab:\|\
set noerrorbells vb t_vb=
]]
set.foldenable = false
set.number = true
set.linebreak = true -- Break lines at word (requires Wrap lines)
set.list = true
set.listchars = { tab = "❯ ", trail = "⋅", extends = "❯", precedes = "❮" }
vim.cmd [[set noerrorbells vb t_vb=]]
set.number = true -- Show line numbers
set.omnifunc = "syntaxcomplete#Complete"
set.scrolloff = 1
set.showcmd = true
set.showmatch = true
set.smartcase = true
set.showmatch = true -- Highlight matching brace
set.smartcase = true -- Enable smart-case search
vim.cmd [[set termencoding=utf-8]]
set.textwidth = 100
set.visualbell = true
set.textwidth = 100 -- Line wrap (number of cols)
set.visualbell = true -- Use visual bell (no beeping)

-- Delete Selected word from whole file
map {'n', '<Leader>s', ':%s/<<C-r><C-w>>//g<Left><Left>'}

map { "n", "<Leader>s", ":%s/<<C-r><C-w>>//g<Left><Left>" }
-- Stop C-r from being seen as backspace
map {'n', '<BS>', ':TmuxNavigateLeft<cr>'}

map { "n", "<BS>", ":TmuxNavigateLeft<cr>" }
-- \R reloads ~/.vimrc
map {'n', '<Bslash>R', ':<C-U>source $MYVIMRC<CR>'}

map { "n", "<Bslash>R", ":<C-U>source $MYVIMRC<CR>" }
-- \DEL deletes the current buffer
map {'n', '<Bslash><Delete>', ':bdelete<CR>'}

map { "n", "<Bslash><Delete>", ":bdelete<CR>" }
-- \INS edits a new buffer
map {'n', '<Bslash><Insert>', ':<C-U>enew<CR>'}

map { "n", "<Bslash><Insert>", ":<C-U>enew<CR>" }
-- \/ types :vimgrep for me ready to enter a search pattern
map {'n', '<Bslash>/', ':<C-U>vimgrep /c/ **<S-Left><S-Left><Right>'}

map { "n", "<Bslash>/", ":<C-U>vimgrep /c/ **<S-Left><S-Left><Right>" }
-- \p toggles paste mode
map {'n', '<Bslash>p', ':<C-U>set paste! paste?<CR>'}
map { "n", "<Bslash>p", ":<C-U>set paste! paste?<CR>" }

+ 9
- 10
config/nvim/lua/hipster.lua View File

@@ -1,8 +1,8 @@
local hipster = {}

local WORDS_IN_SENTENCE = {min = 5, max = 15}
local SENTENCES_IN_PARAGRAPH = {min = 2, max = 7 }
local PARAGRAPHS_IN_TEXT = {min = 2, max = 7 }
local WORDS_IN_SENTENCE = { min = 5, max = 15 }
local SENTENCES_IN_PARAGRAPH = { min = 2, max = 7 }
local PARAGRAPHS_IN_TEXT = { min = 2, max = 7 }

local function random_int(min, max)
return math.random(min, max)
@@ -20,7 +20,7 @@ Craft beer chia readymade ethnic, hella kogi Vice jean shorts cliche cray mlkshk

local function get_words(phrase)
local list = {}
for word in phrase:gmatch('%a+') do
for word in phrase:gmatch "%a+" do
table.insert(list, word:lower())
end
return list
@@ -28,9 +28,8 @@ end

hipster._dict = get_words(BASE_PHRASE)


function hipster:word()
return hipster._dict[random_int(1, #(hipster._dict))]
return hipster._dict[random_int(1, #hipster._dict)]
end

function hipster:sentence()
@@ -39,7 +38,7 @@ function hipster:sentence()
for i = 1, n do
words[i] = hipster:word()
end
local s = table.concat(words, ' ')
local s = table.concat(words, " ")
s = s .. "."
s = s:sub(1, 1):upper() .. s:sub(2)
return s
@@ -51,7 +50,7 @@ function hipster:paragraph()
for i = 1, n do
sentences[i] = hipster:sentence()
end
return table.concat(sentences, ' ')
return table.concat(sentences, " ")
end

function hipster:text()
@@ -60,11 +59,11 @@ function hipster:text()
for i = 1, n do
paragraphs[i] = hipster:paragraph()
end
return table.concat(paragraphs, '\n')
return table.concat(paragraphs, "\n")
end

function hipster:output()
vim.cmd('normal A'..hipster:text():gsub("\n", "\r"))
vim.cmd("normal A" .. hipster:text():gsub("\n", "\r"))
end

return hipster

+ 65
- 43
config/nvim/lua/plugins.lua View File

@@ -1,46 +1,68 @@
local Plug = vim.fn['plug#']
-- load vim-plug if it does not exist in the dotfiles
vim.cmd [[
let plugpath = '~/.local/share/nvim/site/autoload/plug.vim'
if empty(glob(plugpath))
if executable('curl')
echom "Installing vim-plug at " . plugpath
let plugurl = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
call system('curl -fLo ' . shellescape(plugpath) . ' --create-dirs ' . plugurl)
if v:shell_error
echom "Error downloading vim-plug. Please install it manually.\n"
exit
endif
augroup Plugins
au!
au VimEnter * PlugInstall | source $MYVIMRC
else
echom "vim-plug not installed. Please install it manually or install curl.\n"
exit
endif
endif
]]

vim.call('functions#PlugLoad')
vim.call('plug#begin', '~/.local/share/nvim')
local Plug = vim.fn["plug#"]
vim.call("plug#begin", "~/.local/share/nvim")

Plug('Yggdroot/indentLine')
Plug('cespare/vim-toml', {['for']='toml'})
Plug('chrisbra/csv.vim', {['for']='csv'})
Plug('christoomey/vim-tmux-navigator')
Plug('dense-analysis/ale')
Plug('nathanmsmith/nvim-ale-diagnostic')
Plug('ekalinin/Dockerfile.vim', {['for']=[['Dockerfile', 'docker-compose']]})
Plug('elzr/vim-json')
Plug('fatih/vim-go', {['do']=':GoInstallBinaries', ['for']=[['go', 'gohtmltmpl']]})
Plug('godlygeek/tabular')
Plug('plasticboy/vim-markdown')
Plug('google/vim-jsonnet')
Plug('gregsexton/gitv')
Plug('hashivim/vim-terraform')
Plug('hrsh7th/nvim-cmp')
Plug('hrsh7th/vim-vsnip')
Plug('hrsh7th/cmp-buffer')
Plug('leafgarland/typescript-vim', {['for']=[['typescript.tsx', 'typescriptreact', 'typescript',
'vue']]})
Plug('mhinz/vim-signify')
Plug('mhinz/vim-startify')
Plug('moll/vim-node')
Plug('neovim/nvim-lspconfig')
Plug('kabouzeid/nvim-lspinstall')
Plug('nvim-treesitter/nvim-treesitter', {['branch']='0.5-compat', ['do']=':TSUpdate'})
Plug('pangloss/vim-javascript', {['for']=[['typescript.tsx', 'typescriptreact', 'javascript', 'vue']]})
Plug('racer-rust/vim-racer', {['for']='rust'})
Plug('rodjek/vim-puppet')
Plug('rust-lang/rust.vim', {['for']='rust'})
Plug('ryanoasis/vim-devicons')
Plug('scrooloose/nerdcommenter')
Plug('scrooloose/nerdtree')
Plug('Xuyuanp/nerdtree-git-plugin')
Plug('sheerun/vim-polyglot')
Plug('sickill/vim-monokai')
Plug('tpope/vim-fugitive')
Plug('tpope/vim-surround')
Plug('vim-airline/vim-airline')
Plug('vim-airline/vim-airline-themes')
Plug "Yggdroot/indentLine"
Plug("cespare/vim-toml", { ["for"] = "toml" })
Plug("chrisbra/csv.vim", { ["for"] = "csv" })
Plug "christoomey/vim-tmux-navigator"
Plug "dense-analysis/ale"
Plug "nathanmsmith/nvim-ale-diagnostic"
Plug("ekalinin/Dockerfile.vim", { ["for"] = [['Dockerfile', 'docker-compose']] })
Plug "elzr/vim-json"
Plug("fatih/vim-go", { ["do"] = ":GoInstallBinaries", ["for"] = [['go', 'gohtmltmpl']] })
Plug "godlygeek/tabular"
Plug "plasticboy/vim-markdown"
Plug "google/vim-jsonnet"
Plug "gregsexton/gitv"
Plug "hashivim/vim-terraform"
Plug "hrsh7th/nvim-cmp"
Plug "hrsh7th/vim-vsnip"
Plug "hrsh7th/cmp-buffer"
Plug("leafgarland/typescript-vim", {
["for"] = [['typescript.tsx', 'typescriptreact', 'typescript',
'vue']],
})
Plug "mhinz/vim-signify"
Plug "mhinz/vim-startify"
Plug "moll/vim-node"
Plug "neovim/nvim-lspconfig"
Plug "kabouzeid/nvim-lspinstall"
Plug("nvim-treesitter/nvim-treesitter", { ["branch"] = "0.5-compat", ["do"] = ":TSUpdate" })
Plug("pangloss/vim-javascript", { ["for"] = [['typescript.tsx', 'typescriptreact', 'javascript', 'vue']] })
Plug("racer-rust/vim-racer", { ["for"] = "rust" })
Plug "rodjek/vim-puppet"
Plug("rust-lang/rust.vim", { ["for"] = "rust" })
Plug "ryanoasis/vim-devicons"
Plug "scrooloose/nerdcommenter"
Plug "scrooloose/nerdtree"
Plug "Xuyuanp/nerdtree-git-plugin"
Plug "sheerun/vim-polyglot"
Plug "sickill/vim-monokai"
Plug "tpope/vim-fugitive"
Plug "tpope/vim-surround"
Plug "vim-airline/vim-airline"
Plug "vim-airline/vim-airline-themes"

vim.call('plug#end')
vim.call "plug#end"

+ 32
- 14
config/nvim/lua/utils.lua View File

@@ -1,21 +1,39 @@
local utils = {}
local api = vim.api

utils.map = function (key)
-- get the extra options
local opts = { noremap=true, silent=true }
for i, v in pairs(key) do
if type(i) == 'string' then opts[i] = v end
end
utils.map = function(key)
-- get the extra options
local opts = { noremap = true, silent = true }
for i, v in pairs(key) do
if type(i) == "string" then
opts[i] = v
end
end

-- basic support for buffer-scoped keybindings
local buffer = opts.buffer
opts.buffer = nil
-- basic support for buffer-scoped keybindings
local buffer = opts.buffer
opts.buffer = nil

if buffer then
vim.api.nvim_buf_set_keymap(0, key[1], key[2], key[3], opts)
else
vim.api.nvim_set_keymap(key[1], key[2], key[3], opts)
end
if buffer then
api.nvim_buf_set_keymap(0, key[1], key[2], key[3], opts)
else
api.nvim_set_keymap(key[1], key[2], key[3], opts)
end
end

utils.create_augroups = function(definitions)
for group_name, definition in pairs(definitions) do
api.nvim_command("augroup " .. group_name)
api.nvim_command "autocmd!"
for _, def in ipairs(definition) do
-- if type(def) == 'table' and type(def[#def]) == 'function' then
-- def[#def] = lua_callback(def[#def])
-- end
local command = table.concat(vim.tbl_flatten { "autocmd", def }, " ")
api.nvim_command(command)
end
api.nvim_command "augroup END"
end
end

return utils

+ 55
- 54
config/nvim/plugin/ale.lua View File

@@ -1,68 +1,69 @@
local utils = require('utils')
local utils = require "utils"

vim.g['ale_fixers'] = {
['javascript'] = [['prettier', 'eslint']],
['typescript'] = [['prettier', 'tslint', 'eslint']],
['typescriptreact'] = [['prettier', 'tslint', 'eslint']],
['html'] = [['eslint']],
['json'] = [['prettier', 'fixjson', 'jq']],
['scss'] = [['prettier', 'stylelint']],
['css'] = [['prettier', 'stylelint']],
['less'] = [['prettier', 'stylelint']],
['stylus'] = [['stylelint']],
['c'] = [['clang-format']],
['cpp'] = [['clang-format']],
['rust'] = [['rustfmt']],
['python'] = [['yapf', 'isort', 'black']],
['zsh'] = [['shfmt']],
['sh'] = [['shfmt']],
['go'] = [['gofmt', 'goimports']],
['markdown'] = [['prettier']],
['vue'] = [['prettier']],
['yaml'] = [['prettier']],
['ansible'] = [['prettier']],
['puppet'] = [['puppetlint']],
['java'] = [['google_java_format']]
vim.g["ale_fixers"] = {
["javascript"] = { "prettier", "eslint" },
["typescript"] = { "prettier", "tslint", "eslint" },
["typescriptreact"] = { "prettier", "tslint", "eslint" },
["html"] = { "eslint" },
["json"] = { "prettier", "fixjson", "jq" },
["scss"] = { "prettier", "stylelint" },
["css"] = { "prettier", "stylelint" },
["less"] = { "prettier", "stylelint" },
["stylus"] = { "stylelint" },
["c"] = { "clang-format" },
["cpp"] = { "clang-format" },
["rust"] = { "rustfmt" },
["python"] = { "autoimport", "yapf", "isort", "black" },
["zsh"] = { "shfmt" },
["sh"] = { "shfmt" },
["go"] = { "gofmt", "goimports" },
["markdown"] = { "prettier" },
["vue"] = { "prettier" },
["yaml"] = { "prettier" },
["ansible"] = { "prettier" },
["puppet"] = { "puppetlint" },
["java"] = { "google_java_format" },
["lua"] = { "lua-format", "stylua" },
}
vim.g['ale_fix_on_save'] = 1
vim.g['ale_go_gofmt_options'] = '-s'
vim.g['ale_go_gometalinter_options'] = '--fast'
vim.g['ale_go_golangci_lint_options'] = '--fast'
vim.g['ale_go_golangci_lint_package'] = 1
vim.g['ale_rust_cargo_use_clippy'] = 1
vim.g['ale_rust_analyzer_config'] = {
['rust-analyzer'] = {
['assist'] = {
['importMergeBehavior'] = 'last',
['importPrefix'] = 'by_self',
vim.g["ale_fix_on_save"] = 1
vim.g["ale_go_gofmt_options"] = "-s"
vim.g["ale_go_gometalinter_options"] = "--fast"
vim.g["ale_go_golangci_lint_options"] = "--fast"
vim.g["ale_go_golangci_lint_package"] = 1
vim.g["ale_rust_cargo_use_clippy"] = 1
vim.g["ale_rust_analyzer_config"] = {
["rust-analyzer"] = {
["assist"] = {
["importMergeBehavior"] = "last",
["importPrefix"] = "by_self",
},
['cargo.loadOutDirsFromCheck'] = true,
['procMacro.enable'] = true
}
["cargo.loadOutDirsFromCheck"] = true,
["procMacro.enable"] = true,
},
}
vim.g['ale_linters'] = {
['go'] = [['golangci-lint', 'gobuild', 'golint']],
['rust'] = [['cargo', 'rls']],
['typescript'] = [['tslint', 'tsserver', 'typecheck']]
vim.g["ale_linters"] = {
["go"] = { "golangci-lint", "gobuild", "golint" },
["rust"] = { "cargo", "rls" },
["typescript"] = { "tslint", "tsserver", "typecheck" },
}
vim.g['ale_completion_enabled'] = 1
vim.g['ale_echo_msg_error_str'] = 'E'
vim.g['ale_echo_msg_warning_str'] = 'W'
vim.g['ale_echo_msg_format'] = '[%linter%] [%severity%] %code = %%s '
vim.g["ale_completion_enabled"] = 1
vim.g["ale_echo_msg_error_str"] = "E"
vim.g["ale_echo_msg_warning_str"] = "W"
vim.g["ale_echo_msg_format"] = "[%linter%] [%severity%] %code = %%s "

-- alt k & j to jump through errors
utils.map{'n', '<M-k>', '<Plug>(ale_previous_wrap)'}
utils.map{'n', '<M-j>', '<Plug>(ale_next_wrap)'}
utils.map { "n", "<M-k>", "<Plug>(ale_previous_wrap)" }
utils.map { "n", "<M-j>", "<Plug>(ale_next_wrap)" }

-- Disable for minified code and enable whitespace trimming
vim.g['ale_pattern_options'] = {
['.min.js$'] = {['ale_linters'] = [[]], ['ale_fixers'] = [[]]},
['.min.css$'] = {['ale_linters'] = [[]], ['ale_fixers'] = [[]]},
['*'] = {['ale_fixers'] = [['trim_whitespace', 'remove_trailing_lines']]}
vim.g["ale_pattern_options"] = {
[".min.js$"] = { ["ale_linters"] = {}, ["ale_fixers"] = {} },
[".min.css$"] = { ["ale_linters"] = {}, ["ale_fixers"] = {} },
["*"] = { ["ale_fixers"] = { "trim_whitespace", "remove_trailing_lines" } },
}

vim.g['ale_set_loclist'] = 0
vim.g['ale_set_quickfix'] = 1
vim.g["ale_set_loclist"] = 0
vim.g["ale_set_quickfix"] = 1

-- Define :ALEToggleFixer command to Disable autofix globally
vim.cmd [[


+ 74
- 69
config/nvim/plugin/lsp.lua View File

@@ -1,102 +1,107 @@
local map = require('utils').map
local nvim_lsp_config = require('lspconfig')
local nvim_lsp_install = require('lspinstall')
local cmp = require('cmp')
require("nvim-ale-diagnostic")
local map = require("utils").map
local nvim_lsp_config = require "lspconfig"
local nvim_lsp_install = require "lspinstall"
local cmp = require "cmp"
require "nvim-ale-diagnostic"

vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
underline = false,
virtual_text = false,
signs = true,
update_in_insert = false,
}
)
})

-- keymaps
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end

-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Enable completion triggered by <c-x><c-o>
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")

-- Mappings.
map{'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>'}
map{'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>'}
map{'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>'}
map{'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>'}
map{'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>'}
map{'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>'}
map{'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>'}
map{'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>'}
map{'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>'}
map{'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>'}
map{'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>'}
map{'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>'}
map{'n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>'}
map{'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>'}
map{'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>'}
map{'n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>'}
-- Mappings.
map { "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>" }
map { "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>" }
map { "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>" }
map { "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>" }
map { "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>" }
map { "n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>" }
map { "n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>" }
map { "n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>" }
map { "n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>" }
map { "n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>" }
map { "n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>" }
map { "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>" }
map { "n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>" }
map { "n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>" }
map { "n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>" }
map { "n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>" }

-- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then
map{"n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>"}
elseif client.resolved_capabilities.document_range_formatting then
map{"n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>"}
end
-- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then
map { "n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>" }
elseif client.resolved_capabilities.document_range_formatting then
map { "n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>" }
end

-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec([[
-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec(
[[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]], false)
end
]],
false
)
end
end

-- config that activates keymaps and enables snippet support
local function make_config()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
return {
-- enable snippet support
capabilities = capabilities,
-- map buffer local keybindings when the language server attaches
on_attach = on_attach,
}
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
return {
-- enable snippet support
capabilities = capabilities,
-- map buffer local keybindings when the language server attaches
on_attach = on_attach,
}
end

-- lsp-install
local function setup_servers()
require'lspinstall'.setup()
-- get all installed servers
local servers = nvim_lsp_install.installed_servers()
require("lspinstall").setup()
-- get all installed servers
local servers = nvim_lsp_install.installed_servers()

for _, server in pairs(servers) do
local config = make_config()
nvim_lsp_config[server].setup(config)
end
for _, server in pairs(servers) do
local config = make_config()
nvim_lsp_config[server].setup(config)
end
end

setup_servers()

-- Automatically reload after `:LspInstall <server>` so we don't have to restart neovim
nvim_lsp_install.post_install_hook = function ()
setup_servers() -- reload installed servers
vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
nvim_lsp_install.post_install_hook = function()
setup_servers() -- reload installed servers
vim.cmd "bufdo e"
end

cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-y>'] = cmp.mapping.confirm({ select = true }),
},
})
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
["<C-y>"] = cmp.mapping.confirm { select = true },
},
}

+ 57
- 0
config/nvim/plugin/nerdtree.lua View File

@@ -0,0 +1,57 @@
local utils = require "utils"
local g = vim.g
local call = vim.call

local autocmds = {
NERDTree = {
{ "StdinReadPre", "*", "let s:std_in=1" },
{
"BufEnter",
"*",
"if (winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree()) | q | endif",
},
{
"VimEnter",
"*",
[[if !argc() && !exists('s:std_in') | Startify | NERDTree | wincmd w | else | NERDTree | wincmd w | endif]],
},
},
}

utils.create_augroups(autocmds)
utils.map { "", "<C-n>", ":NERDTreeToggle<CR>" }

g.NERDTreeDirArrowExpandable = "▸"
g.NERDTreeDirArrowCollapsible = "▾"
g.NERDTreeGitStatusIndicatorMapCustom = {
["Modified"] = "✹",
["Staged"] = "✚",
["Untracked"] = "✭",
["Renamed"] = "➜",
["Unmerged"] = "═",
["Deleted"] = "✖",
["Dirty"] = "✗",
["Clean"] = "✔︎",
["Unknown"] = "?",
}
-- NERDTress File highlighting
vim.cmd [[
function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
endfunction
]]

call("NERDTreeHighlightFile", "jade", "green", "none", "green", "#151515")
call("NERDTreeHighlightFile", "ini", "yellow", "none", "yellow", "#151515")
call("NERDTreeHighlightFile", "md", "blue", "none", "#3366FF", "#151515")
call("NERDTreeHighlightFile", "yml", "yellow", "none", "yellow", "#151515")
call("NERDTreeHighlightFile", "config", "yellow", "none", "yellow", "#151515")
call("NERDTreeHighlightFile", "conf", "yellow", "none", "yellow", "#151515")
call("NERDTreeHighlightFile", "json", "yellow", "none", "yellow", "#151515")
call("NERDTreeHighlightFile", "html", "yellow", "none", "yellow", "#151515")
call("NERDTreeHighlightFile", "styl", "cyan", "none", "cyan", "#151515")
call("NERDTreeHighlightFile", "css", "cyan", "none", "cyan", "#151515")
call("NERDTreeHighlightFile", "coffee", "Red", "none", "red", "#151515")
call("NERDTreeHighlightFile", "js", "Red", "none", "#ffa500", "#151515")
call("NERDTreeHighlightFile", "php", "Magenta", "none", "#ff00ff", "#151515")

+ 0
- 47
config/nvim/plugin/nerdtree.vim View File

@@ -1,47 +0,0 @@
scriptencoding utf-8
augroup NERDTree
au!
au StdinReadPre * let s:std_in=1
au VimEnter *
\ if !argc() && !exists('s:std_in')
\ | Startify
\ | NERDTree
\ | wincmd w
\ | else
\ | NERDTree
\ | wincmd w
\ | endif
au bufenter * if (winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree()) | q | endif
augroup END
map <C-n> :NERDTreeToggle<CR>
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ 'Modified' : '✹',
\ 'Staged' : '✚',
\ 'Untracked' : '✭',
\ 'Renamed' : '➜',
\ 'Unmerged' : '═',
\ 'Deleted' : '✖',
\ 'Dirty' : '✗',
\ 'Clean' : '✔︎',
\ 'Unknown' : '?'
\ }
" NERDTress File highlighting
function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
endfunction
call NERDTreeHighlightFile('jade' , 'green' , 'none' , 'green' , '#151515')
call NERDTreeHighlightFile('ini' , 'yellow' , 'none' , 'yellow' , '#151515')
call NERDTreeHighlightFile('md' , 'blue' , 'none' , '#3366FF' , '#151515')
call NERDTreeHighlightFile('yml' , 'yellow' , 'none' , 'yellow' , '#151515')
call NERDTreeHighlightFile('config' , 'yellow' , 'none' , 'yellow' , '#151515')
call NERDTreeHighlightFile('conf' , 'yellow' , 'none' , 'yellow' , '#151515')
call NERDTreeHighlightFile('json' , 'yellow' , 'none' , 'yellow' , '#151515')
call NERDTreeHighlightFile('html' , 'yellow' , 'none' , 'yellow' , '#151515')
call NERDTreeHighlightFile('styl' , 'cyan' , 'none' , 'cyan' , '#151515')
call NERDTreeHighlightFile('css' , 'cyan' , 'none' , 'cyan' , '#151515')
call NERDTreeHighlightFile('coffee' , 'Red' , 'none' , 'red' , '#151515')
call NERDTreeHighlightFile('js' , 'Red' , 'none' , '#ffa500' , '#151515')
call NERDTreeHighlightFile('php' , 'Magenta' , 'none' , '#ff00ff' , '#151515')

+ 22
- 22
config/nvim/plugin/startify.lua View File

@@ -5,16 +5,16 @@ local fn = vim.fn
g.startify_files_number = 10
g.startify_change_to_dir = 0
local ascii = {
[[]],
[[ /___/\]],
[[ _\ \/_/\]],
[[ __\ \/_/\ .--.--.|__|.--.--.--.]],
[[ \ __ __ \ \ | | || || |]],
[[ __\ \_\ \_\ \ \ __ \___/ |__||__|__|__|]],
[[ /_/\\ __ __ \ \_/_/\]],
[[ \_\/_\__\/\__\/\__\/_\_\/]],
[[ \_\/_/\ /_\_\/]],
[[ \_\/ \_\/]]
[[]],
[[ /___/\]],
[[ _\ \/_/\]],
[[ __\ \/_/\ .--.--.|__|.--.--.--.]],
[[ \ __ __ \ \ | | || || |]],
[[ __\ \_\ \_\ \ \ __ \___/ |__||__|__|__|]],
[[ /_/\\ __ __ \ \_/_/\]],
[[ \_\/_\__\/\__\/\__\/_\_\/]],
[[ \_\/_/\ /_\_\/]],
[[ \_\/ \_\/]],
}

-- g.startify_custom_header = 'startify#center(g:ascii)'
@@ -23,22 +23,22 @@ g.startify_relative_path = 1
g.startify_use_env = 1

g.startify_lists = {
{type = "dir", header = {"Files: " .. fn.getcwd()}},
{type = "sessions", header = {"Sessions"}},
{type = "bookmarks", header = {"Bookmarks"}},
{type = "commands", header = {"Commands"}}
{ type = "dir", header = { "Files: " .. fn.getcwd() } },
{ type = "sessions", header = { "Sessions" } },
{ type = "bookmarks", header = { "Bookmarks" } },
{ type = "commands", header = { "Commands" } },
}

g.startify_commands = {
{up = {"Update Plugins", ":PlugUpdate"}},
{ug = {"Upgrade Plugin Manager", ":PlugUpgrade"}},
{ts = {"Update Treesitter", "TSUpdate"}},
{ch = {"Check Health", "checkhealth"}}
{ up = { "Update Plugins", ":PlugUpdate" } },
{ ug = { "Upgrade Plugin Manager", ":PlugUpgrade" } },
{ ts = { "Update Treesitter", "TSUpdate" } },
{ ch = { "Check Health", "checkhealth" } },
}

g.startify_bookmarks = {
{c = "~/.config/nvim/init.vim"},
{g = "~/.gitconfig"},
{z = "~/.zshrc"}
{ c = "~/.config/nvim/init.vim" },
{ g = "~/.gitconfig" },
{ z = "~/.zshrc" },
}
map{"n", "<leader>st", ":Startify<cr>"}
map { "n", "<leader>st", ":Startify<cr>" }

+ 6
- 0
config/nvim/stylua.toml View File

@@ -0,0 +1,6 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferDouble"
no_call_parentheses = true

Loading…
Cancel
Save