Browse Source

derpherp

main
Cian Butler 1 month ago
parent
commit
fe294ea44b
Signed by: butlerx GPG Key ID: B37CA765BAA89170
7 changed files with 214 additions and 47 deletions
  1. +19
    -16
      config/nvim/init.vim
  2. +70
    -0
      config/nvim/lua/hipster.lua
  3. +102
    -0
      config/nvim/lua/lsp.lua
  4. +4
    -7
      config/nvim/plugin/hipster.vim
  5. +0
    -2
      config/nvim/plugin/wiki.vim
  6. +18
    -21
      vimrc
  7. +1
    -1
      zshrc

+ 19
- 16
config/nvim/init.vim View File

@@ -44,10 +44,13 @@ set autoindent " Use indent of previous line on new lines
set expandtab " Use spaces instead of tabs
set shiftwidth=2 " Indent with two spaces
set softtabstop=2 " Insert two spaces with tab key
set smartindent " Enable smart-indent
set smarttab " Enable smart-tabs
set tabstop=2
set cindent shiftwidth=2

" Let me backspace over pretty much anything
set backspace=2
set backspace=indent,eol,start

" Indent wrapped lines
silent! set breakindent
@@ -64,12 +67,8 @@ if exists('+completeopt')
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
endif


" Use UTF-8 if we can and env LANG didn't tell us not to
if has('multi_byte') && !exists('$LANG') && &encoding ==# 'latin1'
set encoding=utf-8
else
set completeopt=noinsert,longest,menuone,noselect
endif

" Don't wait for a key after Escape in insert mode
@@ -138,6 +137,10 @@ 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
@@ -163,6 +166,7 @@ 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
@@ -174,30 +178,29 @@ if exists('+virtualedit')
set virtualedit+=block
endif


set diffopt=filler,iwhite
set fileencoding=utf-8
set fillchars+=stl:\ ,stlnc:\
set foldcolumn=1
set foldlevel=0
set foldmethod=indent
set ignorecase
set ignorecase " Always case-insensitive
set laststatus=2
set linebreak
set linebreak " Break lines at word (requires Wrap lines)
set list lcs=tab:\|\
set noerrorbells vb t_vb=
set nofoldenable
set number
set number " Show line numbers
set omnifunc=syntaxcomplete#Complete
set scrolloff=1
set showcmd
set showmatch
set smartcase
set softtabstop=2
set tabstop=2
set showmatch " Highlight matching brace
set smartcase " Enable smart-case search
set termencoding=utf-8
set textwidth=100 " Line wrap (number of cols)
set visualbell " Use visual bell (no beeping)

" Stop C-r from being seen ad backspace
" Stop C-r from being seen as backspace
nnoremap <silent> <BS> :TmuxNavigateLeft<cr>

" \R reloads ~/.vimrc


+ 70
- 0
config/nvim/lua/hipster.lua View File

@@ -0,0 +1,70 @@
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 function random_int(min, max)
return math.random(min, max)
end

local BASE_PHRASE = [[
Hipster ipsum normal iTrust fund fashion axe bitters art party raw denim.
XOXO distillery tofu, letterpress cred literally gluten-free flexitarian fap.
VHS fashion axe gluten-free 90's church-key, kogi hashtag Marfa.
Kogi Tumblr Brooklyn chambray.
Flannel pickled YOLO semiotics.
Mlkshk keffiyeh narwhal, mumblecore gentrify raw denim food truck DIY.
Craft beer chia readymade ethnic, hella kogi Vice jean shorts cliche cray mlkshk ugh cornhole kitsch quinoa.
]]

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

hipster._dict = get_words(BASE_PHRASE)


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

function hipster:sentence()
local n = random_int(WORDS_IN_SENTENCE.min, WORDS_IN_SENTENCE.max)
local words = {}
for i = 1, n do
words[i] = hipster:word()
end
local s = table.concat(words, ' ')
s = s .. "."
s = s:sub(1, 1):upper() .. s:sub(2)
return s
end

function hipster:paragraph()
local n = random_int(SENTENCES_IN_PARAGRAPH.min, SENTENCES_IN_PARAGRAPH.max)
local sentences = {}
for i = 1, n do
sentences[i] = hipster:sentence()
end
return table.concat(sentences, ' ')
end

function hipster:text()
local n = random_int(PARAGRAPHS_IN_TEXT.min, PARAGRAPHS_IN_TEXT.max)
local paragraphs = {}
for i = 1, n do
paragraphs[i] = hipster:paragraph()
end
return table.concat(paragraphs, '\n')
end

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

return hipster

+ 102
- 0
config/nvim/lua/lsp.lua View File

@@ -0,0 +1,102 @@
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, {
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

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

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

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

-- 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
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,
}
end

-- lsp-install
local function setup_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
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
end

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

+ 4
- 7
config/nvim/plugin/hipster.vim View File

@@ -1,8 +1,5 @@
if exists('g:loaded_hipster') | finish | endif

" Define :Hipster command to dump in a paragraph of Hipster ipsum
command! -nargs=0 Hipster :normal iTrust fund fashion axe bitters art party
\ raw denim. XOXO distillery tofu, letterpress cred literally gluten-free
\ flexitarian fap. VHS fashion axe gluten-free 90's church-key, kogi
\ hashtag Marfa. Kogi Tumblr Brooklyn chambray. Flannel pickled YOLO
\ semiotics. Mlkshk keffiyeh narwhal, mumblecore gentrify raw denim food
\ truck DIY. Craft beer chia readymade ethnic, hella kogi Vice jean shorts
\ cliche cray mlkshk ugh cornhole kitsch quinoa
command! -nargs=0 Hipster :lua require'hipster'.output()
let g:loaded_hipster = 1

+ 0
- 2
config/nvim/plugin/wiki.vim View File

@@ -1,2 +0,0 @@
let g:vimwiki_list = [{'path': '~/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}]
let g:vimwiki_global_ext=0

+ 18
- 21
vimrc View File

@@ -1,5 +1,3 @@
runtime system.vim

if has('syntax')
" Use syntax highlighting
if !exists('g:syntax_on')
@@ -25,10 +23,13 @@ set autoindent " Use indent of previous line on new lines
set expandtab " Use spaces instead of tabs
set shiftwidth=2 " Indent with two spaces
set softtabstop=2 " Insert two spaces with tab key
set smartindent " Enable smart-indent
set smarttab " Enable smart-tabs
set tabstop=2
set cindent shiftwidth=2

" Let me backspace over pretty much anything
set backspace=2
set backspace=indent,eol,start

" Indent wrapped lines
silent! set breakindent
@@ -41,14 +42,12 @@ set comments=

" 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
endif


" Use UTF-8 if we can and env LANG didn't tell us not to
if has('multi_byte') && !exists('$LANG') && &encoding ==# 'latin1'
set encoding=utf-8
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
@@ -111,11 +110,7 @@ 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
set ruler " Show row and column ruler information

" Options for file search with gf/:find
set path-=/usr/include " Let the C/C++ filetypes set that
@@ -142,6 +137,7 @@ 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
@@ -160,21 +156,22 @@ set fillchars+=stl:\ ,stlnc:\
set foldcolumn=1
set foldlevel=0
set foldmethod=indent
set ignorecase
set ignorecase " Always case-insensitive
set laststatus=2
set linebreak
set linebreak " Break lines at word (requires Wrap lines)
set list lcs=tab:\|\
set noerrorbells vb t_vb=
set nofoldenable
set number
set number " Show line numbers
set omnifunc=syntaxcomplete#Complete
set scrolloff=1
set showcmd
set showmatch
set smartcase
set softtabstop=2
set tabstop=2
set showmatch " Highlight matching brace
set smartcase " Enable smart-case search
set termencoding=utf-8
set textwidth=100 " Line wrap (number of cols)
set spell " Enable spell-checking
set visualbell " Use visual bell (no beeping)

" Stop C-r from being seen ad backspace
nnoremap <silent> <BS> :TmuxNavigateLeft<cr>


+ 1
- 1
zshrc View File

@@ -5,7 +5,7 @@ for file in ${HOME}/.dotfiles/zsh.d/*.zsh; do
done
fpath=(~/.dotfiles/zsh-completions $fpath)
source "$HOME/.zprofile"
source "/opt/google-cloud-sdk/completion.zsh.inc"
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$HOME/.deno/bin:$PATH"

# The next line updates PATH for Netlify's Git Credential Helper.


Loading…
Cancel
Save