From 2b2219e9986c505b05185a36d26ac76b252a42e0 Mon Sep 17 00:00:00 2001 From: pgfm Date: Sun, 3 Jul 2022 17:37:47 -0500 Subject: [PATCH] Switched to Lua in Neovim. Added ZSH. Updated installation script. --- .config/nvim/init.lua | 11 + .config/nvim/init.vim | 393 ------------------------ .config/nvim/lua/colorscheme.lua | 29 ++ .config/nvim/lua/general.lua | 113 +++++++ .config/nvim/lua/keymap.lua | 129 ++++++++ .config/nvim/lua/packer_init.lua | 145 +++++++++ .config/nvim/lua/plugins/cmp.lua | 26 ++ .config/nvim/lua/plugins/floaterm.lua | 3 + .config/nvim/lua/plugins/lsp.lua | 25 ++ .config/nvim/lua/plugins/lualine.lua | 16 + .config/nvim/lua/plugins/scala.lua | 35 +++ .config/nvim/lua/plugins/telescope.lua | 4 + .config/nvim/lua/plugins/treesitter.lua | 28 ++ .zshrc | 137 +++++++++ install.sh | 120 ++++---- 15 files changed, 755 insertions(+), 459 deletions(-) create mode 100644 .config/nvim/init.lua delete mode 100644 .config/nvim/init.vim create mode 100644 .config/nvim/lua/colorscheme.lua create mode 100644 .config/nvim/lua/general.lua create mode 100644 .config/nvim/lua/keymap.lua create mode 100644 .config/nvim/lua/packer_init.lua create mode 100644 .config/nvim/lua/plugins/cmp.lua create mode 100644 .config/nvim/lua/plugins/floaterm.lua create mode 100644 .config/nvim/lua/plugins/lsp.lua create mode 100644 .config/nvim/lua/plugins/lualine.lua create mode 100644 .config/nvim/lua/plugins/scala.lua create mode 100644 .config/nvim/lua/plugins/telescope.lua create mode 100644 .config/nvim/lua/plugins/treesitter.lua create mode 100644 .zshrc diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..2dd72a1 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,11 @@ +require('packer_init') +require('general') +require('colorscheme') +require('keymap') +require('plugins/lsp') +require('plugins/scala') +require('plugins/cmp') +require('plugins/lualine') +require('plugins/telescope') +require('plugins/floaterm') +require('plugins/treesitter') diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim deleted file mode 100644 index dc9ebea..0000000 --- a/.config/nvim/init.vim +++ /dev/null @@ -1,393 +0,0 @@ -call plug#begin('~/.local/share/nvim/plugged') - -" ============================================================================= -" Key usability plugins -" ============================================================================= - -" FZF Native for Telescope -Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } - -" Floating terminal support for Neovim -Plug 'voldikss/vim-floaterm' - -" Plenary - lua components used by other plugins -Plug 'nvim-lua/plenary.nvim' - -" Neovim LSP -Plug 'neovim/nvim-lspconfig' - -" Completion -Plug 'hrsh7th/cmp-nvim-lsp' " Builtin LSP as a completion source -Plug 'hrsh7th/cmp-path' " Support for path as a completion source -Plug 'hrsh7th/cmp-buffer' " Support for loaded buffers as completion source -Plug 'hrsh7th/nvim-cmp' " Primary plugin - -" Treesitter -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} - -" telescope.nvim -" Gaze deeply into unknown regions using the power of the moon. -Plug 'nvim-telescope/telescope.nvim' - -" trouble.nvim -" A pretty list for showing diagnostics, references, telescope results, quickfix -" and location lists to help you solve all the trouble your code is causing. -Plug 'folke/trouble.nvim' - -" nvim-lint (compatible with Neovim LSP) -" nvim-lint is meant to fill the gaps for languages where either no language -" server exists, or where standalone linters provide better results than the -" available language server do. -Plug 'mfussenegger/nvim-lint' - -" vim-gitgutter -" A Vim plugin which shows a git diff in the sign column. -Plug 'airblade/vim-gitgutter' - -" ============================================================================= -" Languages and project type support. -" ============================================================================= - -" Janet Support -Plug 'janet-lang/janet.vim', { 'for': ['janet'] } - -" Racket Support -Plug 'wlangstroth/vim-racket', { 'for': ['rkt'] } - -" Generalized support for LISPs (Clojure, Racket, Janet) -Plug 'Olical/conjure', { 'tag': 'v4.25.0', 'for': ['janet'] } - -" Zig Support -Plug 'ziglang/zig.vim', { 'for': ['zig'] } - -" Scala Support -" Note: Metals should not be configured with the other LSP items. -Plug 'scalameta/nvim-metals', { 'for': ['scala', 'sbt'] } - -" LaTeX Support -Plug 'lervag/vimtex', { 'for': ['tex'] } - -" Odin Support -Plug 'Tetralux/odin.vim' - -" ============================================================================= -" Visual enhancements -" ============================================================================= - -Plug 'sainnhe/gruvbox-material' -" Plug 'rebelot/kanagawa.nvim' - -Plug 'nvim-lualine/lualine.nvim' - -Plug 'kyazdani42/nvim-web-devicons' -Plug 'folke/lsp-colors.nvim' - -call plug#end() - -" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -filetype plugin indent on - -" Only allow syntax to be set once. -if !exists('g:syntax_on') - syntax enable -endif - -let mapleader=',' -let maplocalleader=',' - -" === Color Scheme === {{ -set termguicolors -set background=dark -let g:gruvbox_material_palette = 'mix' -let g:gruvbox_material_background = 'hard' -let g:gruvbox_material_enable_bold = 1 -colorscheme gruvbox-material -"colorscheme kanagawa - -" === History and Undo Levels === {{ -set history=512 -set undolevels=128 -set undofile -set undodir=~/.config/nvim/undo -" }} - -" === Assorted Core Settings === {{ -set noswapfile -set modelines=0 -set hidden " Hide buffers -set encoding=utf-8 " Always use UTF-8 explicitly -set number " Show line numbers by default -set cursorline " Highlight the current line -set showcmd " Display incomplete commands at the bottom -set noerrorbells " ... we just don't like beeping -set visualbell " Flash rather than beep -set t_vb= " Don't flash please -set ttyfast " Some optimizations for rendering -set ruler " Show row and column number -set laststatus=2 " Last window has a status line -set showmatch " Show matching parens -set lazyredraw " redraw only when necessary, hopefully more efficient. -set pastetoggle= " Cheap way to paste toggle -set colorcolumn=80 " Right margin display -set shortmess-=F " Ensure audocmd works for filetype -set shortmess+=c " Avoid showing extra message when using completion -set spelllang=en_us -set signcolumn=yes -set updatetime=200 -" }} - -" === Basic Completion Settings === {{ -" menu = use a popup menu to show possible completions -" menuone = show a menu even if there is only one match -" noinsert = do not insert text for a match until user selects one -" noselect = do not select a match from the menu automatically -set completeopt=menu,menuone,noinsert,noselect - -" Enable completions as you type. -let g:completion_enable_auto_popup = 1 -" }} - -" === Indentation === {{ -set tabstop=4 -set shiftwidth=4 -set softtabstop=4 -set expandtab -set smarttab -set autoindent -" }} - -" === Search Settings === {{ -set ignorecase -set smartcase -set incsearch -set showmatch -set hlsearch -" }} - -" === General Ignores === {{ -set wildignore=*.class,*.pyc,*.swp,*.o,*.jar -set wildignore+=*/tmp/*,*.zip,*.tar,*.gz,*.bz2,*.xz -set wildignore+=*/.git/* -set wildignore+=*/.metals/*,*/.bloop/*,*/.bsp/* -set wildignore+=*/node_modules/* -" }} - -" === Key Mappings === {{ - -" Use Tab and Shift+Tab to navigate popup menus -inoremap pumvisible() ? "\" : "\" -inoremap pumvisible() ? "\" : "\" - -" Clear search highlighting -nmap / :nohlsearch - -" Save current buffer -nnoremap s :up - -" Move to previous buffer -nnoremap bp :bp - -" Move to next buffer -nnoremap bn :bn - -" Delete current buffer -nnoremap bd :bd - -" Press ; to show a list of active buffers (+ fuzzy search) -nmap ; :Buffers - -" Press Ctrl+P to show a list of files (+ fuzzy search) -nmap :Files - -" Close the quickfix window (example: this shows up when showing references -" via LSP). -nnoremap cq :ccl - -" Telescope Bindings (e.g. file and buffer search) -nnoremap Telescope find_files -nnoremap ; Telescope buffers -nnoremap fg Telescope live_grep -nnoremap fh Telescope help_tags -nnoremap fm Telescope metals commands - -" Trouble bindings -nnoremap xx TroubleToggle -nnoremap xw TroubleToggle workspace_diagnostics -nnoremap xd TroubleToggle document_diagnostics -nnoremap xq TroubleToggle quickfix -nnoremap xl TroubleToggle loclist -nnoremap gR TroubleToggle lsp_references - -" gitgutter bindings -nmap ]h (GitGutterNextHunk) -nmap [h (GitGutterPrevHunk) - -" LSP key bindings -nnoremap K lua vim.lsp.buf.hover() -nnoremap gi lua vim.lsp.buf.implementation() -nnoremap gr lua vim.lsp.buf.references() -nnoremap gds lua vim.lsp.buf.document_symbol() -nnoremap gws lua vim.lsp.buf.workspace_symbol() -nnoremap gd lua vim.lsp.buf.definition() -nnoremap cl lua vim.lsp.codelens.run() -nnoremap D lua vim.lsp.buf.type_definition() -nnoremap rn lua vim.lsp.buf.rename() -nnoremap ca lua vim.lsp.buf.code_action() -nnoremap q lua vim.lsp.diagnostic.set_loclist() -nnoremap e lua vim.lsp.diagnostic.open_float() -nnoremap [c lua vim.diagnostic.goto_prev { wrap = false } -nnoremap ]c lua vim.diagnostic.goto_next { wrap = false } - -" Window movement -map j -map k -map h -map l -" }} - -" === netrw === {{ -let g:netrw_banner = 0 -let g:netrw_liststyle = 3 -let g:netrw_browse_split = 4 -let g:netrw_altv = 1 -let g:netrw_winsize = 25 -" }} - -" === floaterm Configuration === {{ -let g:floaterm_keymap_new = 'tc' -let g:floaterm_keymap_prev = 'tp' -let g:floaterm_keymap_next = 'tn' -let g:floaterm_keymap_toggle = 'tt' -let g:floaterm_width = 0.8 -let g:floaterm_height = 0.8 -let g:floaterm_gitcommit = 'split' -" }} - -" === nvim-cmp Configuration (Completion Plugin) === {{ -lua << EOF -local cmp = require("cmp") -cmp.setup({ - sources = { - { name = "nvim_lsp" }, - { name = "path" }, - { name = 'buffer', option = { keyword_length = 3 }, }, - }, - mapping = { - [""] = cmp.mapping.confirm({}), - [""] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, - [""] = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, - }, -}) -EOF -" }} - -" === LSP Configuration === {{ -lua << EOF -local lsp = require('lspconfig') - --- Use an on_attach function to configure after LSP attaches to buffer -local on_attach = function(client, bufnr) - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -end - --- advertise the nvim-cmp capabilities to LSP servers -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) - --- zls = zig language server -lsp.zls.setup { - on_attach = on_attach, - flags = { - debounce_text_changes = 150 - }, - capabilities = capabilities -} - --- texlab = latex language server -lsp.texlab.setup{} - --- Note that metals is totally separate and doesn't use lspconfig. -metals_config = require("metals").bare_config() - -metals_config.settings = { - showImplicitArguments = true, - showInferredType = true -} - --- This is a tricky option and _nothing_ will show up unless... --- "However, to enable this you _must_ have the metals status shown in your --- status bar somehow." -metals_config.init_options.statusBarProvider = "on" - -metals_config.capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) - --- Autocmd that will actually be in charging of starting the whole thing -local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) -vim.api.nvim_create_autocmd("FileType", { - pattern = { "scala", "sbt", "java" }, - callback = function() - require("metals").initialize_or_attach(metals_config) - end, - group = nvim_metals_group, -}) -EOF -" }} - -" === Treesitter Configuration === {{ -lua </', ':nohlsearch') + +-- Save current buffer +map('n', 's', ':up') + +-- Move to previous buffer +map('n', 'bp', ':bp') + +-- Move to next buffer +map('n', 'bn', ':bn') + +-- Delete current buffer +map('n', 'bd', ':bd') + +-- Close the quickfix window +map('n', 'cq', ':ccl') + +-- Use Tab to jump to the next option in a popup menu +vim.keymap.set('i', '', function() + return vim.fn.pumvisible() == 1 and '' or '' +end, {expr = true}) + +-- Use Shift+Tab to jump to the previous option in a popup menu +vim.keymap.set('i', '', function() + return vim.fn.pumvisible() == 1 and '' or '' +end, {expr = true}) + +----------------------------------------------------------- +-- Telescope +----------------------------------------------------------- + +-- Use ';' to search active buffers +map('n', ';', 'Telescope buffers') + +-- Use Ctrl+P to show a list of files +map('n', '', 'Telescope find_files') + +-- Live Grep +map('n', 'fg', 'Telescope live_grep') + +-- Metals commands +map('n', 'fm', 'Telescope metals commands') + +----------------------------------------------------------- +-- Trouble +----------------------------------------------------------- + +-- Show/hide Trouble +map('n', 'xx', 'TroubleToggle') + +-- Show workspace diagnostics +map('n', 'xw', 'TroubleToggle workspace_diagnostics') + +-- Show document diagnostics +map('n', 'xd', 'TroubleToggle document_diagnostics') + +-- Show quickfix +map('n', 'xq', 'TroubleToggle quickfix') + +-- Show local list +map('n', 'xl', 'TroubleToggle loclist') + +-- Show LSP references +map('n', 'xr', 'TroubleToggle lsp_references') + +----------------------------------------------------------- +-- Floaterm +----------------------------------------------------------- + +-- Create a new floating terminal +vim.g.floaterm_keymap_new = 'tc' + +-- Move to the previous terminal +vim.g.floaterm_keymap_prev = 'tp' + +-- Move to the next terminal +vim.g.floaterm_keymap_next = 'tn' + +-- Toggle the visibility of the floating terminal +vim.g.floaterm_keymap_toggle = 'tt' + +----------------------------------------------------------- +-- nnn File Manager +----------------------------------------------------------- + +-- Toggle the nnn file explorer in a vertical split. +map('n', 'n', 'NnnExplorer') + +-- Toggle the nnn file picker in a floating window. +map('n', 'p', 'NnnPicker %:p:h') + +----------------------------------------------------------- +-- LSP +----------------------------------------------------------- + +map('n', 'K', 'lua vim.lsp.buf.hover()') +map('n', 'gi', 'lua vim.lsp.buf.implementation()') +map('n', 'gr', 'lua vim.lsp.buf.references()') +map('n', 'gds', 'lua vim.lsp.buf.document_symbol()') +map('n', 'gws', 'lua vim.lsp.buf.workspace_symbol()') +map('n', 'gd', 'lua vim.lsp.buf.definition()') +map('n', 'cl', 'lua vim.lsp.codelens.run()') +map('n', 'D', 'lua vim.lsp.buf.type_definition()') +map('n', 'rn', 'lua vim.lsp.buf.rename()') +map('n', 'ca', 'lua vim.lsp.buf.code_action()') +map('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()') +map('n', 'e', 'lua vim.lsp.diagnostic.open_float()') +map('n', '[c', 'lua vim.diagnostic.goto_prev { wrap = false }') +map('n', ']c', 'lua vim.diagnostic.goto_next { wrap = false }') diff --git a/.config/nvim/lua/packer_init.lua b/.config/nvim/lua/packer_init.lua new file mode 100644 index 0000000..833bfd5 --- /dev/null +++ b/.config/nvim/lua/packer_init.lua @@ -0,0 +1,145 @@ +-- Automatically install packer +local fn = vim.fn +local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' + +if fn.empty(fn.glob(install_path)) > 0 then + packer_bootstrap = fn.system({ + 'git', + 'clone', + '--depth', + '1', + 'https://github.com/wbthomason/packer.nvim', + install_path + }) + vim.o.runtimepath = vim.fn.stdpath('data') .. '/site/pack/*/start/*,' .. vim.o.runtimepath +end + +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, 'packer') +if not status_ok then + return +end + +return require('packer').startup(function(use) + -- Plugin/package manager. + use 'wbthomason/packer.nvim' + + -- Required for a number of Lua plugins. + use 'nvim-lua/plenary.nvim' + + -- Color schemes + use 'sainnhe/gruvbox-material' + use 'rebelot/kanagawa.nvim' + use 'marko-cerovac/material.nvim' + + -- Telescope: fuzzy finder + use { + 'nvim-telescope/telescope.nvim', + requires = { + { 'nvim-lua/plenary.nvim' } + } + } + + -- Native Telescope implementation based on FZF for performance. + use { + 'nvim-telescope/telescope-fzf-native.nvim', + run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' + } + + -- A pretty list for showing diagnostics, references, telescope results, + -- quickfix and location lists to help you solve all the trouble your code + -- is causing. + use { + 'folke/trouble.nvim', + requires = 'kyazdani42/nvim-web-devicons', + config = function() + require('trouble').setup() + end + } + + -- Treesitter: Neovim bindings for the Tree-sitter parser generator tool and + -- incremental parsing library. + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate' + } + + -- Neovim-native LSP Implementation + use 'neovim/nvim-lspconfig' + + -- nvim-cmp - completion plugin, used for LSP and Metals + use { + 'hrsh7th/nvim-cmp', + requires = { + 'hrsh7th/cmp-nvim-lsp', -- add once LSP is supported + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-buffer' + } + } + + -- Metals, for Scala development. + use { + 'scalameta/nvim-metals', + requires = { 'nvim-lua/plenary.nvim' }, + --ft = { 'scala', 'sbt' } -- this is busted for some reason. + } + + -- Lualine (configures the bottom bars) + use { + 'nvim-lualine/lualine.nvim', + requires = 'kyazdani42/nvim-web-devicons' + } + + -- bufferline - shows a bar at the top with open buffers + -- using packer.nvim + use { + 'akinsho/bufferline.nvim', + requires = 'kyazdani42/nvim-web-devicons', + config = function() + require('bufferline').setup() + end + } + + -- Floating terminal + use 'voldikss/vim-floaterm' + + -- Show signs for Git + use { + 'lewis6991/gitsigns.nvim', + config = function() + require('gitsigns').setup() + end + } + + -- Show unobtrusive indentation guides + use { + 'lukas-reineke/indent-blankline.nvim', + config = function() + require('indent_blankline').setup() + end + } + + -- File manager for Neovim (backed by nnn) + use { + 'luukvbaal/nnn.nvim', + config = function() + require('nnn').setup() + end + } + + -- Improve startup time by replacing default filetype autocmds + use 'nathom/filetype.nvim' + + -- Improve the core vim.ui + use 'stevearc/dressing.nvim' + + -- Special highlighting and tracking for certain notable words + use { + 'folke/todo-comments.nvim', + requires = 'nvim-lua/plenary.nvim', + config = function() + require('todo-comments').setup() + end + } + +end) diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua new file mode 100644 index 0000000..8bdf6a3 --- /dev/null +++ b/.config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,26 @@ +local cmp = require('cmp') + +cmp.setup{ + sources = { + { name = 'nvim_lsp' }, + { name = 'path' }, + { name = 'buffer', option = { keyword_length = 3 }, }, + }, + mapping = { + [''] = cmp.mapping.confirm({}), + [''] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, + [''] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, + }, +} diff --git a/.config/nvim/lua/plugins/floaterm.lua b/.config/nvim/lua/plugins/floaterm.lua new file mode 100644 index 0000000..ee4583e --- /dev/null +++ b/.config/nvim/lua/plugins/floaterm.lua @@ -0,0 +1,3 @@ +vim.g.floaterm_width = 0.8 +vim.g.floaterm_height = 0.8 +vim.g.floaterm_gitcommit = 'split' diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..4a0f84f --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,25 @@ +local lsp = require('lspconfig') + +-- Use an on_attach function to configure after LSP attaches to buffer +local on_attach = function(client, bufnr) + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') +end + +-- Advertise the nvim-cmp capabilities to LSP servers +local capabilities = vim.lsp.protocol.make_client_capabilities() + +-- nvim-cmp support. +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + +-- zls = zig language server +lsp.zls.setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150 + }, + capabilities = capabilities +} + +-- texlab = latex language server +lsp.texlab.setup{} diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..550af10 --- /dev/null +++ b/.config/nvim/lua/plugins/lualine.lua @@ -0,0 +1,16 @@ +-- Awaiting metals setup +local function metals_status_for_lualine() + return vim.g["metals_status"] or "" +end + +require('lualine').setup { + options = { + theme = 'material' + }, + sections = { + lualine_c = { + 'filename', + metals_status_for_lualine + } + } +} diff --git a/.config/nvim/lua/plugins/scala.lua b/.config/nvim/lua/plugins/scala.lua new file mode 100644 index 0000000..113ab3d --- /dev/null +++ b/.config/nvim/lua/plugins/scala.lua @@ -0,0 +1,35 @@ +-- Note that Metals _does not use nvim-lspconfig_. +-- It still uses the nvim LSP, however. + +-- Autocmd that will actually be in charging of starting the whole thing +local nvim_metals_group = vim.api.nvim_create_augroup( + 'nvim-metals', + { + clear = true + } +) + +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'scala', 'sbt', 'java' }, + callback = function() + metals_config = require('metals').bare_config() + + -- Capabilities for completion. + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + + metals_config.settings = { + showImplicitArguments = true, + showInferredType = true + } + + -- This is a tricky option and _nothing_ will show up unless... + -- "However, to enable this you _must_ have the metals status shown in your + -- status bar somehow." + metals_config.init_options.statusBarProvider = 'on' + + metals_config.capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + require('metals').initialize_or_attach(metals_config) + end, + group = nvim_metals_group, +}) diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..8d47b2f --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,4 @@ +require('telescope').setup() + +-- This is required to use FZF with Telescope. +require('telescope').load_extension('fzf') diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..d5464ea --- /dev/null +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,28 @@ +require'nvim-treesitter.configs'.setup { + -- One of "all", "maintained", or a list of languages + ensure_installed = { + "c", "zig", "bash", "scala", "yaml", "html", "css", "javascript", + "latex", "clojure", "lua", "cpp" + }, + + -- Install languages synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- List of parsers to ignore installing + ignore_install = { }, + + highlight = { + enable = true, + disable = {}, + -- Setting this to true will run `:h syntax` and tree-sitter at the same + -- time. Set this to `true` if you depend on 'syntax' being enabled (like + -- for indentation). Using this option may slow down your editor, and you + -- may see some duplicate highlights. Instead of true it can also be a list + -- of languages + additional_vim_regex_highlighting = false, + }, + + indent = { + enable = true + } +} diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..edd537a --- /dev/null +++ b/.zshrc @@ -0,0 +1,137 @@ +export ZSH="$HOME/.oh-my-zsh" + +ZSH_THEME="spaceship" +SPACESHIP_TIME_SHOW=true +SPACESHIP_TIME_FORMAT="%D{%D %r}" +SPACESHIP_HG_SHOW=false +SPACESHIP_HG_BRANCH_SHOW=false +SPACESHIP_HG_STATUS_SHOW=false +SPACESHIP_XCODE_SHOW_LOCAL=false +SPACESHIP_SWIFT_SHOW_LOCAL=false +SPACESHIP_PHP_SHOW=false +SPACESHIP_AWS_SHOW=false +SPACESHIP_GCLOUD_SHOW=false +SPACESHIP_CONDA_SHOW=false +SPACESHIP_DOTNET_SHOW=false +SPACESHIP_EMBER_SHOW=false +SPACESHIP_BATTERY_SHOW=false + +VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +DISABLE_UNTRACKED_FILES_DIRTY="true" + +plugins=(gitfast vi-mode) + +source $ZSH/oh-my-zsh.sh + +# ============================================================================= +# Personalized Logging for Shell Setup +# ============================================================================= +logging_enabled=false +log_dir="$HOME/log/$USER" +log_file="$log_dir/shell.log" + +if [ -d "$log_dir" ]; then + export SHELL_LOG_FILE="$log_file" + logging_enabled=true + touch "$SHELL_LOG_FILE" +fi + +# ============================================================================= +# Common Environment Configuration +# ============================================================================= +export EDITOR=nvim + +# ============================================================================= +# PATH +# ============================================================================= +if [ -d "$HOME/bin" ]; then + export PATH="$HOME/bin:$PATH" +fi + +if [ -d "$HOME/.local/bin" ]; then + export PATH="$HOME/.local/bin:$PATH" +fi + +if [ -f "$HOME/.cargo/env" ]; then + source "$HOME/.cargo/env" +fi + +if [ -f ~/.fzf.zsh ]; then + source ~/.fzf.zsh +fi + +export RACKET_HOME="$HOME/opt/racket" +if [ -d "$RACKET_HOME" ]; then + export PATH="$RACKET_HOME/bin:$PATH" +fi + +export BUILDKIT_HOME="$HOME/opt/buildkit" +if [ -d "$BUILDKIT_HOME" ]; then + export PATH="$HOME/opt/buildkit/bin:$PATH" +fi + +export JAVA_HOME="$HOME/opt/jdk" +if [ -d "$JAVA_HOME/bin" ]; then + export PATH="$JAVA_HOME/bin:$PATH" +fi + +export COURSIER_HOME="$HOME/.local/share/coursier" +if [ -d "$COURSIER_HOME/bin" ]; then + export PATH="$COURSIER_HOME/bin:$PATH" +fi + +export N_PREFIX=/home/pfm/.n +if [ -d "$N_PREFIX/bin" ]; then + export PATH="$N_PREFIX/bin:$PATH" +fi + +# ============================================================================= +# SSH Agent Management +# ============================================================================= +ssh_agent_startup_file="$HOME/.startup/start-ssh-agent" +if [ -f "$ssh_agent_startup_file" ]; then + source "$ssh_agent_startup_file" +else + if $logging_enabled; then + echo "[warn] SSH Agent startup code missing at " \ + "'$ssh_agent_startup_file': " \ + "see git@git.sr.ht:~eidolon/scripts" >> "$log_file" + fi +fi + +# ============================================================================= +# Aliases +# ============================================================================= +if command -v exa > /dev/null 2>&1; then + alias ls='exa' + alias ll='exa -l' +else + if $logging_enabled; then + echo "[warn] exa is not setup! Using the system ls" >> "$log_file" + fi +fi + +if command -v nvim > /dev/null 2>&1; then + alias vim='nvim' +else + if $logging_enabled; then + echo "[warn] Neovim is not setup! Using the system vim" >> "$log_file" + fi +fi + +# ============================================================================= +# Scala/SBT Setup +# ============================================================================= +if command -v sbt > /dev/null 2>&1; then + export SBT_OPTS="-XX:+UseG1GC -Xmx2048m" +fi + +# ============================================================================= +# Enable Command Syntax Highlighting +# This must be the last item in this file. +# ============================================================================= +source $HOME/src/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh diff --git a/install.sh b/install.sh index 5f847dd..ed22e28 100755 --- a/install.sh +++ b/install.sh @@ -30,6 +30,12 @@ bashrc_source="${__dir}/${bashrc}" bashrc_target="${HOME}/${bashrc}" bashrc_backup="${backup_dir}/${bashrc_name}" +zshrc=".zshrc" +zshrc_name="zshrc" +zshrc_source="${__dir}/${zshrc}" +zshrc_target="${HOME}/${zshrc}" +zshrc_backup="${backup_dir}/${zshrc_name}" + ps1=".startup/ps1" ps1_name="ps1" ps1_source="${__dir}/${ps1}" @@ -90,64 +96,8 @@ ssh_agent_source="${__dir}/${ssh_agent}" ssh_agent_target="${HOME}/${ssh_agent}" ssh_agent_backup="${backup_dir}/${ssh_agent_name}" -# Note: neovim is spread across several files, and this might be a rather -# inefficient way to do this. Alas, will deal with it for now. -nvim=".config/nvim/init.vim" -nvim_name="nvim" -nvim_source="${__dir}/${nvim}" -nvim_target="${HOME}/${nvim}" -nvim_backup="${backup_dir}/${nvim_name}" - -nvim_json=".local/share/nvim/site/ftplugin/json.vim" -nvim_json_name="nvim_json" -nvim_json_source="${__dir}/${nvim_json}" -nvim_json_target="${HOME}/${nvim_json}" -nvim_json_backup="${backup_dir}/${nvim_json_name}" - -nvim_tex=".local/share/nvim/site/ftplugin/tex.vim" -nvim_tex_name="nvim_tex" -nvim_tex_source="${__dir}/${nvim_tex}" -nvim_tex_target="${HOME}/${nvim_tex}" -nvim_tex_backup="${backup_dir}/${nvim_tex_name}" - -nvim_lint=".local/share/nvim/site/plugin/nvim-lint.vim" -nvim_lint_name="nvim_lint" -nvim_lint_source="${__dir}/${nvim_lint}" -nvim_lint_target="${HOME}/${nvim_lint}" -nvim_lint_backup="${backup_dir}/${nvim_lint_name}" - -nvim_web_devicons=".local/share/nvim/site/plugin/nvim-web-devicons.vim" -nvim_web_devicons_name="nvim_web_devicons" -nvim_web_devicons_source="${__dir}/${nvim_web_devicons}" -nvim_web_devicons_target="${HOME}/${nvim_web_devicons}" -nvim_web_devicons_backup="${backup_dir}/${nvim_web_devicons_name}" - -nvim_telescope=".local/share/nvim/site/plugin/telescope.nvim.vim" -nvim_telescope_name="nvim_telescope" -nvim_telescope_source="${__dir}/${nvim_telescope}" -nvim_telescope_target="${HOME}/${nvim_telescope}" -nvim_telescope_backup="${backup_dir}/${nvim_telescope_name}" - -nvim_trouble=".local/share/nvim/site/plugin/trouble.nvim.vim" -nvim_trouble_name="nvim_trouble" -nvim_trouble_source="${__dir}/${nvim_trouble}" -nvim_trouble_target="${HOME}/${nvim_trouble}" -nvim_trouble_backup="${backup_dir}/${nvim_trouble_name}" - -nvim_gitgutter=".local/share/nvim/site/plugin/vim-gitgutter.vim" -nvim_gitgutter_name="nvim_gitgutter" -nvim_gitgutter_source="${__dir}/${nvim_gitgutter}" -nvim_gitgutter_target="${HOME}/${nvim_gitgutter}" -nvim_gitgutter_backup="${backup_dir}/${nvim_gitgutter_name}" - -nvim_vimtex=".local/share/nvim/site/plugin/vimtex.vim" -nvim_vimtex_name="nvim_vimtex" -nvim_vimtex_source="${__dir}/${nvim_vimtex}" -nvim_vimtex_target="${HOME}/${nvim_vimtex}" -nvim_vimtex_backup="${backup_dir}/${nvim_vimtex_name}" - function display_configs { - echo 'Supported config targets: all, bashrc, ps1, profile, i3, i3status, xresources, gitconfig, gitignore, alacritty, fontconfig, ssh_agent, nvim, nvim_json, nvim_tex, nvim_lint, nvim_web_devicons, nvim_telescope, nvim_trouble, nvim_gitgutter, nvim_vimtex' + echo 'Supported config targets: all, bashrc, zshrc, ps1, profile, i3, i3status, xresources, gitconfig, gitignore, alacritty, fontconfig, ssh_agent, nvim' } function display_usage { @@ -204,6 +154,51 @@ function install_config { fi } +function install_neovim { + + # Used for diagnostic purposes only - describes the configuration. + local config_name="nvim" + + # The location of the configuration to install. + local config_source=".config/nvim/init.lua" + + local lua_source=".config/nvim/lua" + + # The destination where the symbolic link should be created. + local config_target="${HOME}/.config/nvim/init.lua" + + local lua_target="${HOME}/.config/nvim/lua" + + # The backup file for this piece of configuration. + local config_backup="${backup_dir}/${config_name}" + local lua_backup="${backup_dir}/nvim-lua" + + if [ "$config_selection" = "all" ] || [ "${config_selection}" = "${config_name}" ]; then + echo -n -e "${COLOR_SUCCESS}[+]${NC} Installing '${config_name}' to '${config_target}'... " + if [ -f "${config_target}" ]; then + if $auto_backup; then + # The file exists, so create a backup and remove the file. + echo -e "\n\t${COLOR_NOTIFY}[Note]${NC} creating a backup of '${config_target}' and '${lua_target}'" + cp "${config_target}" "${config_backup}" + cp -r "${lua_target}" "${lua_backup}" + rm "${config_target}" + rm -r "${lua_target}" + ln -s "${__dir}/${config_source}" "${config_target}" + ln -s "${__dir}/${lua_source}" "${lua_target}" + echo -e "\t${COLOR_SUCCESS}[Success]${NC}" + else + # The caller does not want backups/deletions, so we must abort. + echo -e "\n\t${COLOR_ERROR}[Error]${NC} Could not install configuration '${config_name}'. This configuration already exists. Please manually remove it or set --auto-backup" + fi + else + # The file doesn't exist, we can safely create a symlink. + ln -s "${__dir}/${config_source}" "${config_target}" + ln -s "${__dir}/${lua_source}" "${lua_target}" + echo -e "${COLOR_SUCCESS}[Success]${NC}" + fi + fi +} + while [[ $# -gt 0 ]] do key="$1" @@ -247,6 +242,7 @@ fi # Install all requested configurations. install_config "${bashrc_name}" "${bashrc_source}" "${bashrc_target}" "${bashrc_backup}" +install_config "${zshrc_name}" "${zshrc_source}" "${zshrc_target}" "${zshrc_backup}" install_config "${ps1_name}" "${ps1_source}" "${ps1_target}" "${ps1_backup}" install_config "${profile_name}" "${profile_source}" "${profile_target}" "${profile_backup}" install_config "${i3_name}" "${i3_source}" "${i3_target}" "${i3_backup}" @@ -259,12 +255,4 @@ install_config "${fontconfig_name}" "${fontconfig_source}" "${fontconfig_target} install_config "${ssh_agent_name}" "${ssh_agent_source}" "${ssh_agent_target}" "${ssh_agent_backup}" # Note that all of these configurations are Neovim-related: -install_config "${nvim_name}" "${nvim_source}" "${nvim_target}" "${nvim_backup}" -install_config "${nvim_json_name}" "${nvim_json_source}" "${nvim_json_target}" "${nvim_json_backup}" -install_config "${nvim_tex_name}" "${nvim_tex_source}" "${nvim_tex_target}" "${nvim_tex_backup}" -install_config "${nvim_lint_name}" "${nvim_lint_source}" "${nvim_lint_target}" "${nvim_lint_backup}" -install_config "${nvim_web_devicons_name}" "${nvim_web_devicons_source}" "${nvim_web_devicons_target}" "${nvim_web_devicons_backup}" -install_config "${nvim_telescope_name}" "${nvim_telescope_source}" "${nvim_telescope_target}" "${nvim_telescope_backup}" -install_config "${nvim_trouble_name}" "${nvim_trouble_source}" "${nvim_trouble_target}" "${nvim_trouble_backup}" -install_config "${nvim_gitgutter_name}" "${nvim_gitgutter_source}" "${nvim_gitgutter_target}" "${nvim_gitgutter_backup}" -install_config "${nvim_vimtex_name}" "${nvim_vimtex_source}" "${nvim_vimtex_target}" "${nvim_vimtex_backup}" +install_neovim