From b5eaa2dc1a59c10023a2b88a0c311c6a2d194180 Mon Sep 17 00:00:00 2001 From: Luke Collier Date: Thu, 14 Apr 2022 12:08:33 +0100 Subject: [PATCH] feat: Updated neovim lsp and metals Added full Brewfile Added support for non x64 chipset --- Brewfile | 50 +++++++++++++++++++++------ alacritty/alacritty.yml | 3 +- install.sh | 7 +++- neovim/init.vim | 76 +++++++++++++++++++++++++++-------------- zsh/zshrc | 8 ++--- 5 files changed, 100 insertions(+), 44 deletions(-) diff --git a/Brewfile b/Brewfile index df4549c..7cf5ede 100644 --- a/Brewfile +++ b/Brewfile @@ -1,16 +1,44 @@ -tap "homebrew/cask-fonts" -cask "font-jetbrains-mono-nerd-font" tap "coursier/formulas" -brew "coursier" -cask "firefox" - -brew "neovim" -brew "tmux" +tap "homebrew/bundle" +tap "homebrew/cask" +tap "homebrew/cask-fonts" +tap "homebrew/core" +tap "homebrew/services" +tap "koekeishiya/formulae" +tap "michaeleisel/zld" +tap "scalacenter/bloop" +brew "awscli" +brew "cdk" +brew "docker" +brew "exa" +brew "fd" brew "fnm" brew "fzf" -brew "zoxide" +brew "jq" +brew "jsonnet" +brew "mill" +brew "neovim" brew "nnn" -brew "zsh" -brew "yabai" +brew "node" +brew "rename" +brew "ripgrep" +brew "rust-analyzer" +brew "rustup-init" brew "starship" -brew "exa" +brew "terraform" +brew "tmux" +brew "websocat" +brew "yarn" +brew "zoxide" +brew "zsh" +brew "coursier/formulas/coursier" +brew "koekeishiya/formulae/yabai", args: ["HEAD"] +cask "alacritty" +cask "blender" +cask "firefox" +cask "font-jetbrains-mono-nerd-font" +cask "gimp" +cask "keybase" +cask "notion" +cask "pgadmin4" +cask "visual-studio-code" diff --git a/alacritty/alacritty.yml b/alacritty/alacritty.yml index 26ec178..54261b3 100644 --- a/alacritty/alacritty.yml +++ b/alacritty/alacritty.yml @@ -144,4 +144,5 @@ debug: vim: nospell - +shell: + program: /bin/zsh diff --git a/install.sh b/install.sh index d0a7eea..3fde6ac 100755 --- a/install.sh +++ b/install.sh @@ -8,7 +8,11 @@ else echo "brew installed skipping" fi -arch -arm64 brew bundle --file ./Brewfile +if [[ $(uname -m) == 'arm64' ]]; then + arch -arm64 brew bundle --file ./Brewfile +else + brew bundle --file ./Brewfile +fi cp -p ./alacritty/alacritty.yml ~/.config/alacritty/alacritty.yml cp -p ./neovim/init.vim ~/.config/nvim/init.vim @@ -24,4 +28,5 @@ git config --global alias.co checkout git config --global alias.br branch git config --global alias.ci commit git config --global alias.st status +git config --global alias.a add echo "setting up git alias" diff --git a/neovim/init.vim b/neovim/init.vim index 2c93c2e..94905e6 100644 --- a/neovim/init.vim +++ b/neovim/init.vim @@ -10,8 +10,10 @@ Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'nvim-lua/completion-nvim' Plug 'nvim-lua/popup.nvim' Plug 'nvim-lua/plenary.nvim' +Plug 'rust-lang/rust.vim' Plug 'neovim/nvim-lsp' Plug 'neovim/nvim-lspconfig' +Plug 'scalameta/nvim-metals' Plug 'nvim-telescope/telescope.nvim' Plug 'vim-test/vim-test' @@ -50,6 +52,9 @@ Plug 'tpope/vim-commentary' Plug 'tpope/vim-unimpaired' Plug 'tpope/vim-projectionist' +" Jsonnet +Plug 'google/vim-jsonnet' + " God junegunn Plug 'Yggdroot/indentLine' Plug 'junegunn/vim-peekaboo' @@ -61,28 +66,62 @@ Plug 'dhruvasagar/vim-table-mode' call plug#end() +let g:rust_clip_command = 'pbcopy' + " -------------------------------------------------------------------------------- " - Language Client - " -------------------------------------------------------------------------------- - -let g:metals_server_version = '0.10.4' +let g:metals_server_version = '0.11.2' " -------------------------------------------------------------------------------- " - Lua Setup - " -------------------------------------------------------------------------------- lua <e', 'lua vim.diagnostic.open_float()', opts) + vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) + vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) + vim.api.nvim_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) + + -- Use an on_attach function to only map the following keys + -- after the language server attaches to the current buffer + local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) + end + + -- Use a loop to conveniently call 'setup' on multiple servers and + -- map buffer local keybindings when the language server attaches + local servers = { 'metals', 'rust_analyzer', 'tsserver' } + for _, lsp in pairs(servers) do + require('lspconfig')[lsp].setup { + on_attach = on_attach, + flags = { + -- This will be the default in neovim 0.7+ + debounce_text_changes = 150, + } + } + end vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()]] require("trouble").setup { @@ -144,22 +183,9 @@ lua < d lua vim.lsp.buf.definition() -nnoremap t lua vim.lsp.buf.type_definition() -nnoremap h lua vim.lsp.buf.hover() -nnoremap H lua vim.lsp.diagnostic.show_line_diagnostics() -nnoremap l lua vim.lsp.diagnostic.set_loclist() -nnoremap i lua vim.lsp.buf.implementation() -nnoremap r lua vim.lsp.buf.references() -nnoremap ws lua vim.lsp.buf.workspace_symbol() -nnoremap rn lua vim.lsp.buf.rename() -" nnoremap ff lua vim.lsp.buf.formatting() -nnoremap a lua vim.lsp.buf.code_action() - au BufWritePre *.scala :lua vim.lsp.buf.formatting() au BufWritePre *.rs :lua vim.lsp.buf.formatting() - " -------------------------------------------------------------------------------- " - Autocomplete - " -------------------------------------------------------------------------------- diff --git a/zsh/zshrc b/zsh/zshrc index 113e638..2c3d15a 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -1,9 +1,5 @@ - -# Local bin on path -export PATH=/Users/lukecollier/.local/bin:$PATH - -# Autojump -[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh +export PATH=/bin:/usr/bin:/usr/local/bin:${PATH} +eval "$(/opt/homebrew/bin/brew shellenv)" # Vi mode bindkey '^P' up-history