neovim! and some tmux adjustment

This commit is contained in:
Erik Stambaugh 2024-06-12 08:57:02 -07:00
parent 6ce3d877f4
commit 0ce81731a0
15 changed files with 614 additions and 3 deletions

View file

@ -0,0 +1 @@
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)

View file

@ -0,0 +1,345 @@
local augroup = vim.api.nvim_create_augroup('config', {clear = false})
-- stolen from https://gitlab.com/Iron_E/dotfiles/-/blob/master/.config/nvim/lua/plugin/heirline.lua
--[[
_ _ _ _ _
| |__ ___(_)_ __| (_)_ __ ___ _ ____ _(_)_ __ ___
| '_ \ / _ \ | '__| | | '_ \ / _ \ | '_ \ \ / / | '_ ` _ \
| | | | __/ | | | | | | | | __/_| | | \ V /| | | | | | |
|_| |_|\___|_|_| |_|_|_| |_|\___(_)_| |_|\_/ |_|_| |_| |_|
--]]
local devicons = require 'nvim-web-devicons'
--[[/* CONSTANTS */]]
-- Defined in https://github.com/Iron-E/nvim-highlite
local BLACK = '#202020'
local BLUE = '#7766ff'
local CYAN = '#33dbc3'
local GRAY_DARK = '#353535'
local GRAY_LIGHT = '#c0c0c0'
local GREEN = '#22ff22'
local GREEN_DARK = '#70d533'
local GREEN_LIGHT = '#99ff99'
local ICE = '#95c5ff'
local MAGENTA = '#d5508f'
local MAGENTA_DARK = '#bb0099'
local ORANGE = '#ff8900'
local ORANGE_LIGHT = '#f0af00'
local PINK = '#ffa6ff'
local PINK_LIGHT = '#ffb7b7'
local PURPLE = '#cf55f0'
local PURPLE_LIGHT = '#af60af'
local RED = '#ee4a59'
local RED_DARK = '#a80000'
local RED_LIGHT = '#ff4090'
local TAN = '#f4c069'
local TEAL = '#60afff'
local TURQOISE = '#2bff99'
local WHITE = '#ffffff'
local YELLOW = '#f0df33'
local SIDEBAR = BLACK
local MIDBAR = GRAY_DARK
local TEXT = GRAY_LIGHT
--[[/* HELPERS */]]
--- The width of the screen
local columns = vim.api.nvim_get_option_value('columns', {})
vim.api.nvim_create_autocmd('VimResized', {
callback = function() columns = vim.api.nvim_get_option_value('columns', {}) end,
group = 'config',
})
do
local command = 'doautocmd User BufEnterOrGitSignsUpdate'
vim.api.nvim_create_autocmd('BufEnter', {command = command, group = 'config'})
vim.api.nvim_create_autocmd('User', {command = command, group = 'config', pattern = 'GitSignsUpdate'})
end
--- Set buffer variables for file icon and color.
--- @return {color: string, icon: string}
local function buf_init_devicons()
local icon, color = devicons.get_icon(vim.fn.expand '%:t', vim.fn.expand '%:e', {default = true})
local dev_icons = {color = vim.api.nvim_get_hl(0, {link = false, name = color}).fg, icon = icon}
vim.b.dev_icons = dev_icons
return dev_icons
end
--- @return {color: string, icon: string}
local function filetype_info()
return vim.b.dev_icons or buf_init_devicons()
end
--- Redraw the statusline
local redrawstatus = vim.schedule_wrap(function() vim.api.nvim_command 'redrawstatus' end)
--[[/* HEIRLINE CONFIG */]]
--- Components separated by this component will be padded with an equal number of spaces.
local ALIGN = {provider = '%='}
--- A left separator.
local LEFT_SEPARATOR = {provider = ''}
--- A right separator.
local RIGHT_SEPARATOR = {provider = ''}
require('heirline').setup({statusline =
{
-- LEFT {{{
{ -- ViMode {{{
hl = function(self)
vim.api.nvim_set_hl(0, self.group, {bg = SIDEBAR, fg = self.color, bold = true})
return self.group
end,
init = function(self)
if vim.g.libmodalActiveModeName then
self.name = vim.g.libmodalActiveModeName
self.color = self.modes[self.name]
else
local current_mode = self.modes[vim.api.nvim_get_mode().mode]
self.name = current_mode[1]
self.color = current_mode[2]
end
end,
provider = function(self) return '' .. self.name .. ' ' end,
static =
{ -- {{{
group = 'HeirlineViMode',
modes =
{
['c'] = {'COMMAND-LINE', RED},
['ce'] = {'NORMAL EX', RED_DARK},
['cv'] = {'EX', RED_LIGHT},
['i'] = {'INSERT', GREEN},
['ic'] = {'INS-COMPLETE', GREEN_LIGHT},
['ix'] = {'INS-COMPLETE', GREEN_LIGHT},
['Rc'] = {'REP-COMPLETE', GREEN_LIGHT},
['Rvc'] = {'VIRT-REP-COMPLETE', GREEN_LIGHT},
['Rvx'] = {'VIRT-REP-COMPLETE', GREEN_LIGHT},
['Rx'] = {'REP-COMPLETE', GREEN_LIGHT},
['n'] = {'NORMAL', PURPLE_LIGHT},
['niI'] = {'INS-NORMAL', PURPLE_LIGHT},
['niR'] = {'REP-NORMAL', PURPLE_LIGHT},
['niV'] = {'VIRT-REP-NORMAL', PURPLE_LIGHT},
['nt'] = {'TERM-NORMAL', PURPLE_LIGHT},
['ntT'] = {'TERM-NORMAL', PURPLE_LIGHT},
['no'] = {'OPERATOR-PENDING', PURPLE},
['nov'] = {'CHAR OPERATOR-PENDING', PURPLE},
['noV'] = {'LINE OPERATOR-PENDING', PURPLE},
['no'] = {'BLOCK OPERATOR-PENDING', PURPLE},
['R'] = {'REPLACE', PINK},
['Rv'] = {'VIRT-REPLACE', PINK_LIGHT},
['r'] = {'HIT-ENTER', CYAN},
['rm'] = {'--MORE', CYAN},
['r?'] = {':CONFIRM', CYAN},
['s'] = {'SELECT', TURQOISE},
['S'] = {'SELECT LINE', TURQOISE},
[''] = {'SELECT', TURQOISE},
['v'] = {'VISUAL', BLUE},
['vs'] = {'SEL-VISUAL', BLUE},
['V'] = {'VISUAL LINE', BLUE},
['Vs'] = {'SEL-VISUAL LINE', BLUE},
[''] = {'VISUAL BLOCK', BLUE},
['s'] = {'VISUAL BLOCK', BLUE},
['t'] = {'TERMINAL', ORANGE},
['!'] = {'SHELL', YELLOW},
-- libmodal
['BUFFERS'] = TEAL,
['TABLES'] = ORANGE_LIGHT,
['TABS'] = TAN,
}
}, -- }}}
update = {'ModeChanged', callback = redrawstatus, pattern = '*:*'},
}, -- }}}
{ -- File Icon {{{
hl = function(self) return {bg = SIDEBAR, fg = self.file.color} end,
init = function(self) self.file = filetype_info() end,
update = 'BufEnter',
LEFT_SEPARATOR,
{
hl = function(self) return {bg = self.file.color, fg = SIDEBAR} end,
provider = function(self) return ' ' .. self.file.icon .. ' %Y ' end,
},
RIGHT_SEPARATOR,
}, -- }}}
{ -- File Info {{{
hl = {bg = SIDEBAR, bold = true, fg = TEXT},
-- File name
{provider = ' %t '},
{ -- Readonly {{{
condition = function() return vim.api.nvim_get_option_value('readonly', {buf = 0}) end,
provider = '',
update = {'OptionSet', pattern = 'readonly'},
}, -- }}}
{ -- Modified {{{
condition = function() return vim.api.nvim_get_option_value('modified', {}) end,
provider = '',
update = 'BufModifiedSet',
}, -- }}}
{ -- File size {{{
init = function(self) self.stat = vim.loop.fs_stat(vim.api.nvim_buf_get_name(0)) end,
update = {'BufEnter', 'BufWritePost'},
{
condition = function(self) return self.stat end,
provider = function(self)
local size = self.stat.size
local i = 1
while size > self.conversion and i < #self.units do
size = size / self.conversion
i = i + 1
end
return ('%.2f%sb '):format(size, self.units[i])
end,
static = {conversion = 1024, units = {'', 'k', 'm', 'g', 't', 'p', 'e', 'z', 'y'}},
},
}, -- }}}
{hl = {fg = MIDBAR}, LEFT_SEPARATOR},
}, -- }}}
-- }}}
-- MIDDLE {{{
{hl = {bg = MIDBAR}, ALIGN},
{ -- Diagnostics {{{
hl = {bg = MIDBAR, fg = SIDEBAR},
init = function(self)
local diagnostics = vim.diagnostic.get(0) --- @type Diagnostic[]
if #diagnostics < 1 then
self.diagnostics = nil
else
self.diagnostics = {0, 0, 0, 0}
for _, diagnostic in ipairs(diagnostics) do
self.diagnostics[diagnostic.severity] = self.diagnostics[diagnostic.severity] + 1
end
end
end,
update = {'BufEnter', 'DiagnosticChanged'},
{
condition = function(self) return self.diagnostics end,
LEFT_SEPARATOR,
{
hl = {bg = SIDEBAR},
static =
{ -- {{{
icons = {'', '', '', ''},
--- @param severity 1|2|3|4
--- @return nil|string
provide = function(self, severity)
if self.diagnostics[severity] > 0 then
local str = self.icons[severity] .. self.diagnostics[severity]
for i = severity + 1, #self.diagnostics do
if self.diagnostics[i] > 0 then
str = str .. ' '
break
end
end
return str
end
end,
}, -- }}}
{hl = {fg = RED}, provider = function(self) return self:provide(vim.diagnostic.severity.ERROR) end},
{hl = {fg = ORANGE}, provider = function(self) return self:provide(vim.diagnostic.severity.WARN) end},
{hl = {fg = PINK_LIGHT}, provider = function(self) return self:provide(vim.diagnostic.severity.INFO) end},
{hl = {fg = MAGENTA}, provider = function(self) return self:provide(vim.diagnostic.severity.HINT) end},
},
RIGHT_SEPARATOR,
},
}, -- }}}
-- }}}
-- RIGHT {{{
{hl = {bg = MIDBAR}, ALIGN},
{ -- Git {{{
init = function(self) self.status = vim.b.gitsigns_status_dict end,
update = {'User', callback = redrawstatus, pattern = 'BufEnterOrGitSignsUpdate'},
{ -- Diff {{{
hl = {bg = MIDBAR},
{
condition = function(self) return self.status end,
static =
{
--- @param sign string
--- @param change string
--- @return nil|string
provide = function(self, sign, change)
local count = self.status[change] or 0
if count > 0 then return sign .. count end
end,
},
{hl = {fg = GREEN}, provider = function(self) return self:provide('+', 'added') end},
{hl = {fg = ORANGE_LIGHT}, provider = function(self) return self:provide('~', 'changed') end},
{hl = {fg = RED_LIGHT}, provider = function(self) return self:provide('-', 'removed') end},
{provider = ' '},
},
}, -- }}}
{ -- Branch {{{
hl = {bg = GREEN_DARK},
{hl = {fg = MIDBAR}, RIGHT_SEPARATOR},
{provider = ' '},
{
condition = function(self) return self.status end,
hl = {fg = SIDEBAR, bold = true},
provider = function(self) return '' .. self.status.head .. ' ' end,
},
{hl = {fg = SIDEBAR}, LEFT_SEPARATOR},
}, -- }}}
}, -- }}}
-- Column Number
{hl = {fg = TEXT, bg = SIDEBAR}, provider = '  %v '},
{ -- Line Percentage {{{
hl = {bg = MAGENTA_DARK},
{hl = {fg = SIDEBAR}, RIGHT_SEPARATOR},
{hl = {fg = WHITE}, provider = ' %p%% '},
}, -- }}}
-- }}}
}})

View file

@ -0,0 +1,50 @@
-- here you can setup the language servers
local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings
-- to learn the available actions
lsp_zero.default_keymaps({buffer = bufnr})
end)
-- to learn how to use mason.nvim
-- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guide/integrate-with-mason-nvim.md
require('mason').setup({})
require('mason-lspconfig').setup({
-- https://github.com/williamboman/mason-lspconfig.nvim?tab=readme-ov-file
ensure_installed = {
"pylsp",
"pyright",
},
handlers = {
function(server_name)
require('lspconfig')[server_name].setup({})
end,
},
})
require "lspconfig".pylsp.setup {
on_attach = on_attach,
settings = {
pylsp = {
plugins = {
flake8 = {
enabled = false,
maxLineLength = 119,
},
mypy = {
enabled = true,
},
pycodestyle = {
enabled = false,
},
pyflakes = {
enabled = false,
},
}
}
}
}

View file

@ -0,0 +1,25 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "javascript", "python" },
--ensure_installed = { "c", "lua", "vim", "vimdoc", "query" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
enable = true,
-- 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,
},
}

View file

@ -0,0 +1 @@
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)

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

@ -0,0 +1 @@
require("erik")

View file

@ -0,0 +1,20 @@
{
"LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"gitsigns.nvim": { "branch": "main", "commit": "de18f6b749f6129eb9042a2038590872df4c94a9" },
"heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" },
"lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" },
"lsp-zero.nvim": { "branch": "v3.x", "commit": "16de3b18c5f7b6230d89b8e64ce9a4801b6f8d08" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" },
"mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" },
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
"nvim-lspconfig": { "branch": "master", "commit": "4d38bece98300e3e5cd24a9aa0d0ebfea4951c16" },
"nvim-treesitter": { "branch": "master", "commit": "26171d8f105d97746371d1b6c07c8d88bf13fec2" },
"nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"telescope.nvim": { "branch": "master", "commit": "f12b15e1b3a33524eb06a1ae7bc852fb1fd92197" },
"tokyonight.nvim": { "branch": "main", "commit": "024621763d91bb48f2b486df529c7aaeb8d6d355" },
"undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" },
"vim-better-whitespace": { "branch": "master", "commit": "029f35c783f1b504f9be086b9ea757a36059c846" },
"vim-fugitive": { "branch": "master", "commit": "4f59455d2388e113bd510e85b310d15b9228ca0d" }
}

View file

@ -0,0 +1,38 @@
require("tokyonight").setup({
-- your configuration comes here
-- or leave it empty to use the default settings
style = "night", -- The theme comes in three styles, `storm`, `moon`, a darker variant `night` and `day`
light_style = "day", -- The theme is used when the background is set to light
transparent = true, -- Enable this to disable setting the background color
terminal_colors = true, -- Configure the colors used when opening a `:terminal` in [Neovim](https://github.com/neovim/neovim)
styles = {
-- Style to be applied to different syntax groups
-- Value is any valid attr-list value for `:help nvim_set_hl`
comments = { italic = true },
--keywords = { italic = true },
keywords = {},
functions = {},
variables = {},
-- Background styles. Can be "dark", "transparent" or "normal"
sidebars = "dark", -- style for sidebars, see below
floats = "dark", -- style for floating windows
},
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]`
day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors
hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**.
dim_inactive = false, -- dims inactive windows
lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold
--- You can override specific color groups to use other groups or a hex color
--- function will be called with a ColorScheme table
---@param colors ColorScheme
on_colors = function(colors) end,
--- You can override specific highlights to use other groups or a hex color
--- function will be called with a Highlights and ColorScheme table
---@param highlights Highlights
---@param colors ColorScheme
on_highlights = function(highlights, colors) end,
})
vim.cmd[[colorscheme tokyonight]]

View file

@ -0,0 +1,4 @@
require("erik.remap")
require("erik.lazy")
require("erik.colorscheme")
require("erik.options")

View file

@ -0,0 +1,71 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
--require("lazy").setup(plugins, opts)
require("lazy").setup({
{
"nvim-telescope/telescope.nvim",
lazy = false,
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>\\', builtin.buffers, {})
end,
},
{ "folke/tokyonight.nvim", lazy = false, priority = 1000, opts = {} },
{
"nvim-treesitter/nvim-treesitter",
lazy = false,
config = function()
vim.cmd('TSUpdate')
end,
},
{ "mbbill/undotree", lazy = false },
{ "tpope/vim-fugitive", lazy = false },
{ "ntpeters/vim-better-whitespace", lazy = false },
-- { "glepnir/galaxyline.nvim", lazy = false },
{
"rebelot/heirline.nvim",
lazy = false,
dependencies = {'gitsigns.nvim', 'nvim-web-devicons'},
},
{ "lewis6991/gitsigns.nvim" },
{ "nvim-tree/nvim-web-devicons" },
-- LSP stuff
--- Uncomment the two plugins below if you want to manage the language servers from neovim
{'williamboman/mason.nvim'},
{'williamboman/mason-lspconfig.nvim'},
{'VonHeikemen/lsp-zero.nvim', branch = 'v3.x'},
{'neovim/nvim-lspconfig'},
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/nvim-cmp'},
{'L3MON4D3/LuaSnip'},
})

View file

@ -0,0 +1,33 @@
vim.opt.incsearch = true -- show search incrementally as it's run
vim.opt.scrolloff = 8 -- try to have at least 8 rows at the bottom of the screen
vim.opt.updatetime = 50
vim.opt.signcolumn = "no" -- no no no
-- from my original vimrc
vim.opt.expandtab = true
-- formatoptions
-- https://vimdoc.sourceforge.net/htmldoc/change.html#fo-table
-- my original was cqr:
-- c: Auto-wrap comments using textwidth, inserting the current comment leader automatically.
-- q: Allow formatting of comments with "gq".
-- r: Automatically insert the current comment leader after hitting <Enter> in Insert mode.
-- default is jcroql:
-- j: (nvim) Where it makes sense, remove a comment leader when joining lines.
-- o: Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode.
-- l: Long lines are not broken in insert mode: When a line was longer than 'textwidth' when the insert command started, Vim does not automatically format it.
--
-- the defaults seem fine
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
-- -- whitespace
-- vim.opt.listchars.tab = " "
-- vim.opt.listchars.trail = " "
-- vim.opt.listchars.extends = "»"
-- vim.opt.listchars.precedes = "«"

View file

@ -0,0 +1,15 @@
vim.g.mapleader = "\\"
vim.keymap.set("n", "<leader>ee", vim.cmd.Ex)
-- other stuff from https://github.com/ThePrimeagen/init.lua/blob/master/lua/theprimeagen/remap.lua
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true }) -- x to make executable
-- from my original vimrc
vim.keymap.set("n", "<C-Z>", vim.cmd.shell)
vim.keymap.set("n", "<C-p>", vim.cmd.bprev)
vim.keymap.set("n", "<C-n>", vim.cmd.bnext)
vim.keymap.set("n", "<leader>q", vim.cmd.nohlsearch)

View file

@ -0,0 +1,4 @@
return {
{ "folke/lazy.nvim", version = false },
{ "nvim-telescope/telescope.nvim", version=false },
}

View file

View file

@ -80,10 +80,13 @@ if-shell "hostname | grep -q meathook" "set -g status-left '#[bg=#1111ff,fg=colo
# Highlight active window # Highlight active window
set-window-option -g window-status-current-format "#[bg=#000011,fg=#112233] #[bg=#000011,fg=#bbffbb]#I:#W #[bg=#112233,fg=#000011]" set-window-option -g window-status-current-format "#[bg=#000011,fg=#112233] #[bg=#000011,fg=#bbffbb]#I:#W #[bg=#112233,fg=#000011]"
set-window-option -g window-status-format " #I:#W " set-window-option -g window-status-format " #I:#W "
set-window-option -g window-status-separator "" # UGH this doesn't work -- tmux falls back to " "
# Inactive windows get low-contrast; active window sharper # Inactive windows get low-contrast; active window sharper
set -g window-style 'fg=colour246,bg=#152030' #set -g window-style 'fg=colour246,bg=#152030'
set -g window-active-style 'fg=colour255,bg=black' set -g window-style 'fg=colour246,bg=#252731'
#set -g window-active-style 'fg=colour255,bg=black'
set -g window-active-style 'fg=colour255,bg=#1e2030'
# Automatically set window title # Automatically set window title
set-option -g set-titles on set-option -g set-titles on