Monorepo for Aesthetic.Computer
aesthetic.computer
1" auto-install vim-plug
2if empty(glob('~/.config/nvim/autoload/plug.vim'))
3 silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
4 \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
5
6 autocmd VimEnter * PlugInstall | source $MYVIMRC
7endif
8
9" specify a directory for storing plugins
10call plug#begin(stdpath('data') . '/plugged')
11
12" list plugins
13Plug 'lifepillar/vim-solarized8'
14Plug 'dag/vim-fish'
15Plug 'ethanholz/nvim-lastplace'
16Plug 'neovim/nvim-lspconfig'
17Plug 'tomlion/vim-solidity'
18Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " We recommend updating the parsers on update
19
20" Initialize plugin system (🗒️ install: https://github.com/junegunn/vimplug)
21call plug#end()
22
23lua require'nvim-lastplace'.setup{}
24
25" enable terminal colors to be set from app
26set termguicolors
27
28" tie to system clipboard
29set clipboard=unnamedplus
30
31" clear inc highlights on esc
32nnoremap <Esc> :noh<CR><Esc>
33
34" choose my favorite colorscheme on my chosen background
35set background=dark
36colorscheme solarized8
37
38" enable line numbers
39set nu
40
41" always scroll with cursor
42set so=0 " 999
43
44" folding
45set foldmethod=indent
46set foldnestmax=10
47" set nofoldenable
48set foldlevelstart=99
49autocmd FileType * setlocal foldenable
50
51" set up tabs (note: eventually exceptions could be added for certain files: https://stackoverflow.com/a/51995699
52set tabstop=2
53set shiftwidth=2
54set expandtab
55set smartindent
56
57" sign gutter
58set signcolumn=yes
59
60" auto apply chezmoi edits: https://www.chezmoi.io/docs/how-to/#use-your-preferred-editor-with-chezmoi-edit-and-" " " chezmoi-edit-config
61" autocmd BufWritePost ~/.local/share/chezmoi/* ! chezmoi apply --source-path "%"
62
63lua << EOF
64-- enable lsp server
65-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#tsserver
66
67-- require'lspconfig'.tsserver.setup{}
68
69-- setup basic lsp
70
71local nvim_lsp = require('lspconfig')
72
73-- Use an on_attach function to only map the following keys
74-- after the language server attaches to the current buffer
75local on_attach = function(client, bufnr)
76 local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
77 local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
78
79 -- Enable completion triggered by <c-x><c-o>
80 buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
81
82 -- Mappings.
83 local opts = { noremap=true, silent=true }
84
85 -- See `:help vim.lsp.*` for documentation on any of the below functions
86 buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
87 buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
88 buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
89 buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
90 buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
91 buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
92 buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
93 buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
94 buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
95 -- buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
96 -- buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
97 buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
98 -- buf_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
99 -- buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
100 -- buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
101 buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
102 buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
103end
104
105-- Use a loop to conveniently call 'setup' on multiple servers and
106-- map buffer local keybindings when the language server attaches
107local servers = { 'tsserver' }
108for _, lsp in ipairs(servers) do
109 nvim_lsp[lsp].setup {
110 on_attach = on_attach,
111 flags = {
112 debounce_text_changes = 150,
113 }
114 }
115end
116EOF