Switched to Lua in Neovim. Added ZSH. Updated installation script.

This commit is contained in:
pgfm 2022-07-03 17:37:47 -05:00
parent 9191504dba
commit 2b2219e998
15 changed files with 755 additions and 459 deletions

11
.config/nvim/init.lua Normal file
View file

@ -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')

View file

@ -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=<F2> " 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 <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" Clear search highlighting
nmap <silent> <leader>/ :nohlsearch<CR>
" Save current buffer
nnoremap <leader>s :up<cr>
" Move to previous buffer
nnoremap <leader>bp :bp<cr>
" Move to next buffer
nnoremap <leader>bn :bn<cr>
" Delete current buffer
nnoremap <leader>bd :bd<cr>
" Press ; to show a list of active buffers (+ fuzzy search)
nmap ; :Buffers<CR>
" Press Ctrl+P to show a list of files (+ fuzzy search)
nmap <C-p> :Files<CR>
" Close the quickfix window (example: this shows up when showing references
" via LSP).
nnoremap <leader>cq :ccl<cr>
" Telescope Bindings (e.g. file and buffer search)
nnoremap <C-p> <cmd>Telescope find_files<cr>
nnoremap ; <cmd>Telescope buffers<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>fm <cmd>Telescope metals commands<cr>
" Trouble bindings
nnoremap <leader>xx <cmd>TroubleToggle<cr>
nnoremap <leader>xw <cmd>TroubleToggle workspace_diagnostics<cr>
nnoremap <leader>xd <cmd>TroubleToggle document_diagnostics<cr>
nnoremap <leader>xq <cmd>TroubleToggle quickfix<cr>
nnoremap <leader>xl <cmd>TroubleToggle loclist<cr>
nnoremap gR <cmd>TroubleToggle lsp_references<cr>
" gitgutter bindings
nmap ]h <Plug>(GitGutterNextHunk)
nmap [h <Plug>(GitGutterPrevHunk)
" LSP key bindings
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> gds <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <silent> gws <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> <leader>cl <cmd>lua vim.lsp.codelens.run()<CR>
nnoremap <silent> <leader>D <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> <leader>rn <cmd>lua vim.lsp.buf.rename()<CR>
nnoremap <silent> <leader>ca <cmd>lua vim.lsp.buf.code_action()<CR>
nnoremap <silent> <leader>q <cmd>lua vim.lsp.diagnostic.set_loclist()<CR>
nnoremap <silent> <leader>e <cmd>lua vim.lsp.diagnostic.open_float()<CR>
nnoremap <silent> [c <cmd>lua vim.diagnostic.goto_prev { wrap = false }<CR>
nnoremap <silent> ]c <cmd>lua vim.diagnostic.goto_next { wrap = false }<CR>
" Window movement
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-h> <C-w>h
map <C-l> <C-w>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 = '<leader>tc'
let g:floaterm_keymap_prev = '<leader>tp'
let g:floaterm_keymap_next = '<leader>tn'
let g:floaterm_keymap_toggle = '<leader>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 = {
["<CR>"] = cmp.mapping.confirm({}),
["<Tab>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end,
["<S-Tab>"] = 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 <<EOF
require'nvim-treesitter.configs'.setup {
-- One of "all", "maintained", or a list of languages
ensure_installed = { "c", "zig", "bash", "scala", "yaml" },
-- 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
}
}
EOF
" }}
" === Lualine Configuration === {{
lua <<EOF
local lualine_gruvbox = require'lualine.themes.gruvbox'
local function metals_status_for_lualine()
return vim.g["metals_status"] or ""
end
require('lualine').setup {
options = { theme = lualine_gruvbox },
sections = { lualine_c = { 'filename', metals_status_for_lualine } }
}
EOF
" }}

View file

@ -0,0 +1,29 @@
-- Set the colorscheme and any related options.
vim.opt.background = 'dark'
-- Settings for gruvbox-material
-- vim.g.gruvbox_material_palette = 'mix'
-- vim.g.gruvbox_material_background = 'hard'
-- vim.g.gruvbox_material_enable_bold = 1
-- vim.cmd 'colorscheme gruvbox-material'
-- Settings for material
vim.g.material_style = "palenight"
require('material').setup({
italics = {
comments = true, -- Enable italic comments
},
plugins = {
neogit = false,
sidebar_nvim = false,
lsp_saga = false,
nvim_dap = false,
nvim_navic = false,
hop = false,
}
})
vim.cmd 'colorscheme material'

View file

@ -0,0 +1,113 @@
local g = vim.g -- Global variables
local opt = vim.opt -- Set options (global/buffer/windows-scoped)
-----------------------------------------------------------
-- General
-----------------------------------------------------------
opt.mouse = 'a' -- Enable mouse support
opt.swapfile = false -- Don't use swapfile
opt.modelines = 0 -- Disable modelines
opt.encoding = 'utf-8' -- Set default encoding to UTF-8
-- Note that this setting is important for which-key. Also don't reduce it too
-- low, or the behavior will start getting wonky and always show which-key.
opt.timeoutlen = 500 -- Time in ms to wait for a sequnece to complete
opt.shortmess:remove("F"):append("c")
opt.wildignore = {
'*.class', '*.pyc', '*.swp', '*.o', '*.jar', '*/tmp/*', '*.zip',
'*.tar', '*.gz', '*.bz2', '*.xz', '*/.git/*', '*/.metals/*',
'*/.bloop/*', '*/.bsp/*', '*/node_modules/*'
}
-----------------------------------------------------------
-- Completion
-----------------------------------------------------------
-- 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
opt.completeopt = 'menu,menuone,noinsert,noselect'
g.completion_enable_auto_popup = 1 -- Enable completions while typing
-----------------------------------------------------------
-- Neovim UI
-----------------------------------------------------------
opt.number = true -- Show line number
opt.cursorline = true -- Highlight the current line
opt.showcmd = true -- Show incomplete commands at the bottom
opt.ttyfast = true -- Rendering optimizations
opt.showmatch = true -- Highlight matching parenthesis
opt.colorcolumn = '80' -- Line length marker at 80 columns
opt.ruler = true -- Show row and column number
opt.signcolumn = 'yes' -- Always show the sign column
opt.foldmethod = 'marker' -- Enable folding (default 'foldmarker')
opt.splitright = true -- Vertical split to the right
opt.splitbelow = true -- Horizontal split to the bottom
opt.linebreak = true -- Wrap on word boundary
opt.termguicolors = true -- Enable 24-bit RGB colors
opt.laststatus = 3 -- Set global statusline
-----------------------------------------------------------
-- Tabs, indent
-----------------------------------------------------------
opt.tabstop = 4
opt.shiftwidth = 4
opt.softtabstop = 4
opt.expandtab = true
opt.smarttab = true
opt.autoindent = true
-----------------------------------------------------------
-- Memory, CPU
-----------------------------------------------------------
opt.hidden = true -- Enable background buffers
opt.lazyredraw = true -- Faster scrolling
opt.synmaxcol = 240 -- Max column for syntax highlight
opt.updatetime = 500 -- ms to wait for trigger an event
-----------------------------------------------------------
-- History
-----------------------------------------------------------
opt.history = 512
opt.undolevels = 128
opt.undofile = true
-----------------------------------------------------------
-- Search
-----------------------------------------------------------
opt.ignorecase = true
opt.smartcase = true
opt.incsearch = true
opt.showmatch = true
opt.hlsearch = true
-----------------------------------------------------------
-- Startup
-----------------------------------------------------------
-- Disable nvim intro
opt.shortmess:append "sI"
-- Disable builtins plugins
local disabled_built_ins = {
"gzip",
"zip",
"zipPlugin",
"tar",
"tarPlugin",
"getscript",
"getscriptPlugin",
"vimball",
"vimballPlugin",
"2html_plugin",
"logipat",
"rrhelper",
"spellfile_plugin",
"matchit"
}
for _, plugin in pairs(disabled_built_ins) do
g["loaded_" .. plugin] = 1
end

129
.config/nvim/lua/keymap.lua Normal file
View file

@ -0,0 +1,129 @@
-----------------------------------------------------------
-- Define keymaps for Neovim and plugins.
-----------------------------------------------------------
local function map(mode, lhs, rhs, opts)
local options = { noremap = true, silent = true }
if opts then
options = vim.tbl_extend('force', options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
-- Change leader to a comma
vim.g.mapleader = ','
-----------------------------------------------------------
-- General
-----------------------------------------------------------
-- Clear search highlighting
map('n', '<leader>/', ':nohlsearch<CR>')
-- Save current buffer
map('n', '<leader>s', ':up<CR>')
-- Move to previous buffer
map('n', '<leader>bp', ':bp<CR>')
-- Move to next buffer
map('n', '<leader>bn', ':bn<CR>')
-- Delete current buffer
map('n', '<leader>bd', ':bd<CR>')
-- Close the quickfix window
map('n', '<leader>cq', ':ccl<CR>')
-- Use Tab to jump to the next option in a popup menu
vim.keymap.set('i', '<Tab>', function()
return vim.fn.pumvisible() == 1 and '<C-N>' or '<Tab>'
end, {expr = true})
-- Use Shift+Tab to jump to the previous option in a popup menu
vim.keymap.set('i', '<S-Tab>', function()
return vim.fn.pumvisible() == 1 and '<C-P>' or '<Tab>'
end, {expr = true})
-----------------------------------------------------------
-- Telescope
-----------------------------------------------------------
-- Use ';' to search active buffers
map('n', ';', '<cmd>Telescope buffers<CR>')
-- Use Ctrl+P to show a list of files
map('n', '<C-P>', '<cmd>Telescope find_files<CR>')
-- Live Grep
map('n', '<leader>fg', '<cmd>Telescope live_grep<CR>')
-- Metals commands
map('n', '<leader>fm', '<cmd>Telescope metals commands<CR>')
-----------------------------------------------------------
-- Trouble
-----------------------------------------------------------
-- Show/hide Trouble
map('n', '<leader>xx', '<cmd>TroubleToggle<CR>')
-- Show workspace diagnostics
map('n', '<leader>xw', '<cmd>TroubleToggle workspace_diagnostics<CR>')
-- Show document diagnostics
map('n', '<leader>xd', '<cmd>TroubleToggle document_diagnostics<CR>')
-- Show quickfix
map('n', '<leader>xq', '<cmd>TroubleToggle quickfix<CR>')
-- Show local list
map('n', '<leader>xl', '<cmd>TroubleToggle loclist<CR>')
-- Show LSP references
map('n', '<leader>xr', '<cmd>TroubleToggle lsp_references<CR>')
-----------------------------------------------------------
-- Floaterm
-----------------------------------------------------------
-- Create a new floating terminal
vim.g.floaterm_keymap_new = '<leader>tc'
-- Move to the previous terminal
vim.g.floaterm_keymap_prev = '<leader>tp'
-- Move to the next terminal
vim.g.floaterm_keymap_next = '<leader>tn'
-- Toggle the visibility of the floating terminal
vim.g.floaterm_keymap_toggle = '<leader>tt'
-----------------------------------------------------------
-- nnn File Manager
-----------------------------------------------------------
-- Toggle the nnn file explorer in a vertical split.
map('n', '<C-A>n', '<cmd>NnnExplorer<CR>')
-- Toggle the nnn file picker in a floating window.
map('n', '<C-A>p', '<cmd>NnnPicker %:p:h<CR>')
-----------------------------------------------------------
-- LSP
-----------------------------------------------------------
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>')
map('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>')
map('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>')
map('n', 'gds', '<cmd>lua vim.lsp.buf.document_symbol()<CR>')
map('n', 'gws', '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>')
map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>')
map('n', '<leader>cl', '<cmd>lua vim.lsp.codelens.run()<CR>')
map('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
map('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>')
map('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>')
map('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>')
map('n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.open_float()<CR>')
map('n', '[c', '<cmd>lua vim.diagnostic.goto_prev { wrap = false }<CR>')
map('n', ']c', '<cmd>lua vim.diagnostic.goto_next { wrap = false }<CR>')

View file

@ -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)

View file

@ -0,0 +1,26 @@
local cmp = require('cmp')
cmp.setup{
sources = {
{ name = 'nvim_lsp' },
{ name = 'path' },
{ name = 'buffer', option = { keyword_length = 3 }, },
},
mapping = {
['<CR>'] = cmp.mapping.confirm({}),
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end,
},
}

View file

@ -0,0 +1,3 @@
vim.g.floaterm_width = 0.8
vim.g.floaterm_height = 0.8
vim.g.floaterm_gitcommit = 'split'

View file

@ -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{}

View file

@ -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
}
}
}

View file

@ -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,
})

View file

@ -0,0 +1,4 @@
require('telescope').setup()
-- This is required to use FZF with Telescope.
require('telescope').load_extension('fzf')

View file

@ -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
}
}

137
.zshrc Normal file
View file

@ -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

View file

@ -30,6 +30,12 @@ bashrc_source="${__dir}/${bashrc}"
bashrc_target="${HOME}/${bashrc}" bashrc_target="${HOME}/${bashrc}"
bashrc_backup="${backup_dir}/${bashrc_name}" 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=".startup/ps1"
ps1_name="ps1" ps1_name="ps1"
ps1_source="${__dir}/${ps1}" ps1_source="${__dir}/${ps1}"
@ -90,64 +96,8 @@ ssh_agent_source="${__dir}/${ssh_agent}"
ssh_agent_target="${HOME}/${ssh_agent}" ssh_agent_target="${HOME}/${ssh_agent}"
ssh_agent_backup="${backup_dir}/${ssh_agent_name}" 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 { 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 { function display_usage {
@ -204,6 +154,51 @@ function install_config {
fi 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 ]] while [[ $# -gt 0 ]]
do do
key="$1" key="$1"
@ -247,6 +242,7 @@ fi
# Install all requested configurations. # Install all requested configurations.
install_config "${bashrc_name}" "${bashrc_source}" "${bashrc_target}" "${bashrc_backup}" 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 "${ps1_name}" "${ps1_source}" "${ps1_target}" "${ps1_backup}"
install_config "${profile_name}" "${profile_source}" "${profile_target}" "${profile_backup}" install_config "${profile_name}" "${profile_source}" "${profile_target}" "${profile_backup}"
install_config "${i3_name}" "${i3_source}" "${i3_target}" "${i3_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}" install_config "${ssh_agent_name}" "${ssh_agent_source}" "${ssh_agent_target}" "${ssh_agent_backup}"
# Note that all of these configurations are Neovim-related: # Note that all of these configurations are Neovim-related:
install_config "${nvim_name}" "${nvim_source}" "${nvim_target}" "${nvim_backup}" install_neovim
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}"