This commit is contained in:
Steve 2023-03-30 21:15:46 -04:00
commit 984dc04492
30 changed files with 2213 additions and 1 deletions

View file

@ -0,0 +1,12 @@
local M = {}
function M.setup()
local {PLUGIN} = require({PLUGIN})
local conf = {
conf = {
}
}
{PLUGIN}.setup(conf)
end
return M

View file

@ -0,0 +1,261 @@
local M = {}
function M.setup()
local aerial = require("aerial")
local conf = {
backends = { "treesitter", "lsp", "markdown", "man" },
float = {
relative = "editor",
override = function(conf)
local padding = 4
conf.anchor = 'NE'
conf.row = padding
conf.col = vim.o.columns - padding
return conf
end,
},
layout = {
-- These control the width of the aerial window.
-- They can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
-- min_width and max_width can be a list of mixed types.
-- max_width = {40, 0.2} means "the lesser of 40 columns or 20% of total"
max_width = { 80, 0.2 },
width = nil,
min_width = 40,
-- key-value pairs of window-local options for aerial window (e.g. winhl)
win_opts = {},
-- Determines the default direction to open the aerial window. The 'prefer'
-- options will open the window in the other direction *if* there is a
-- different buffer in the way of the preferred direction
-- Enum: prefer_right, prefer_left, right, left, float
default_direction = "right",
-- Determines where the aerial window will be opened
-- edge - open aerial at the far right/left of the editor
-- window - open aerial to the right/left of the current window
placement = "edge",
},
-- Determines how the aerial window decides which buffer to display symbols for
-- window - aerial window will display symbols for the buffer in the window from which it was opened
-- global - aerial window will display symbols for the current window
attach_mode = "global",
-- List of enum values that configure when to auto-close the aerial window
-- unfocus - close aerial when you leave the original source window
-- switch_buffer - close aerial when you change buffers in the source window
-- unsupported - close aerial when attaching to a buffer that has no symbol source
close_automatic_events = {},
-- Keymaps in aerial window. Can be any value that `vim.keymap.set` accepts OR a table of keymap
-- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true })
-- Additionally, if it is a string that matches "aerial.<name>",
-- it will use the mapping at require("aerial.action").<name>
-- Set to `false` to remove a keymap
keymaps = {
["?"] = "actions.show_help",
["g?"] = "actions.show_help",
["<CR>"] = "actions.jump",
["<2-LeftMouse>"] = "actions.jump",
["<C-v>"] = "actions.jump_vsplit",
["<C-s>"] = "actions.jump_split",
["p"] = "actions.scroll",
["<C-j>"] = "actions.down_and_scroll",
["<C-k>"] = "actions.up_and_scroll",
["{"] = "actions.prev",
["}"] = "actions.next",
["[["] = "actions.prev_up",
["]]"] = "actions.next_up",
["q"] = "actions.close",
["o"] = "actions.tree_toggle",
["za"] = "actions.tree_toggle",
["O"] = "actions.tree_toggle_recursive",
["zA"] = "actions.tree_toggle_recursive",
["l"] = "actions.tree_open",
["zo"] = "actions.tree_open",
["L"] = "actions.tree_open_recursive",
["zO"] = "actions.tree_open_recursive",
["h"] = "actions.tree_close",
["zc"] = "actions.tree_close",
["H"] = "actions.tree_close_recursive",
["zC"] = "actions.tree_close_recursive",
["zr"] = "actions.tree_increase_fold_level",
["zR"] = "actions.tree_open_all",
["zm"] = "actions.tree_decrease_fold_level",
["zM"] = "actions.tree_close_all",
["zx"] = "actions.tree_sync_folds",
["zX"] = "actions.tree_sync_folds",
},
-- When true, don't load aerial until a command or function is called
-- Defaults to true, unless `on_attach` is provided, then it defaults to false
lazy_load = true,
-- Disable aerial on files with this many lines
disable_max_lines = 10000,
-- Disable aerial on files this size or larger (in bytes)
disable_max_size = 2000000, -- Default 2MB
-- A list of all symbols to display. Set to false to display all symbols.
-- This can be a filetype map (see :help aerial-filetype-map)
-- To see all available values, see :help SymbolKind
filter_kind = {
"Class",
"Constructor",
"Enum",
"Function",
"Interface",
"Module",
"Method",
"Struct",
},
-- Determines line highlighting mode when multiple splits are visible.
-- split_width Each open window will have its cursor location marked in the
-- aerial buffer. Each line will only be partially highlighted
-- to indicate which window is at that location.
-- full_width Each open window will have its cursor location marked as a
-- full-width highlight in the aerial buffer.
-- last Only the most-recently focused window will have its location
-- marked in the aerial buffer.
-- none Do not show the cursor locations in the aerial window.
highlight_mode = "split_width",
-- Highlight the closest symbol if the cursor is not exactly on one.
highlight_closest = true,
-- Highlight the symbol in the source buffer when cursor is in the aerial win
highlight_on_hover = false,
-- When jumping to a symbol, highlight the line for this many ms.
-- Set to false to disable
highlight_on_jump = 300,
-- Define symbol icons. You can also specify "<Symbol>Collapsed" to change the
-- icon when the tree is collapsed at that symbol, or "Collapsed" to specify a
-- default collapsed icon. The default icon set is determined by the
-- "nerd_font" option below.
-- If you have lspkind-nvim installed, it will be the default icon set.
-- This can be a filetype map (see :help aerial-filetype-map)
icons = {},
-- Control which windows and buffers aerial should ignore.
-- If attach_mode is "global", focusing an ignored window/buffer will
-- not cause the aerial window to update.
-- If open_automatic is true, focusing an ignored window/buffer will not
-- cause an aerial window to open.
-- If open_automatic is a function, ignore rules have no effect on aerial
-- window opening behavior; it's entirely handled by the open_automatic
-- function.
ignore = {
-- Ignore unlisted buffers. See :help buflisted
unlisted_buffers = true,
-- List of filetypes to ignore.
filetypes = {},
-- Ignored buftypes.
-- Can be one of the following:
-- false or nil - No buftypes are ignored.
-- "special" - All buffers other than normal buffers are ignored.
-- table - A list of buftypes to ignore. See :help buftype for the
-- possible values.
-- function - A function that returns true if the buffer should be
-- ignored or false if it should not be ignored.
-- Takes two arguments, `bufnr` and `buftype`.
buftypes = "special",
-- Ignored wintypes.
-- Can be one of the following:
-- false or nil - No wintypes are ignored.
-- "special" - All windows other than normal windows are ignored.
-- table - A list of wintypes to ignore. See :help win_gettype() for the
-- possible values.
-- function - A function that returns true if the window should be
-- ignored or false if it should not be ignored.
-- Takes two arguments, `winid` and `wintype`.
wintypes = "special",
},
-- Use symbol tree for folding. Set to true or false to enable/disable
-- Set to "auto" to manage folds if your previous foldmethod was 'manual'
-- This can be a filetype map (see :help aerial-filetype-map)
manage_folds = true,
-- When you fold code with za, zo, or zc, update the aerial tree as well.
-- Only works when manage_folds = true
-- Fold code when you open/collapse symbols in the tree.
-- Only works when manage_folds = true
link_tree_to_folds = true,
-- Set default symbol icons to use patched font icons (see https://www.nerdfonts.com/)
-- "auto" will set it to true if nvim-web-devicons or lspkind-nvim is installed.
nerd_font = "auto",
-- Call this function when aerial attaches to a buffer.
on_attach = function(bufnr) end,
-- Call this function when aerial first sets symbols on a buffer.
on_first_symbols = function(bufnr) end,
-- Automatically open aerial when entering supported buffers.
-- This can be a function (see :help aerial-open-automatic)
open_automatic = false,
-- Run this command after jumping to a symbol (false will disable)
post_jump_cmd = "normal! zz",
-- When true, aerial will automatically close after jumping to a symbol
close_on_select = false,
-- The autocmds that trigger symbols update (not used for LSP backend)
update_events = "TextChanged,InsertLeave",
-- Show box drawing characters for the tree hierarchy
show_guides = true,
guides = {
-- When the child item has a sibling below it
mid_item = "├─",
-- When the child item is the last in the list
last_item = "└─",
-- When there are nested child guides to the right
nested_top = "",
-- Raw indentation
whitespace = " ",
},
lsp = {
-- Fetch document symbols when LSP diagnostics update.
-- If false, will update on buffer changes.
diagnostics_trigger_update = true,
-- Set to false to not update the symbols when there are LSP errors
update_when_errors = true,
-- How long to wait (in ms) after a buffer change before updating
-- Only used when diagnostics_trigger_update = false
update_delay = 300,
},
treesitter = {
-- How long to wait (in ms) after a buffer change before updating
update_delay = 300,
},
markdown = {
-- How long to wait (in ms) after a buffer change before updating
update_delay = 300,
},
man = {
-- How long to wait (in ms) after a buffer change before updating
update_delay = 300,
},
}
aerial.setup(conf)
end
return M

View file

@ -0,0 +1,20 @@
local M = {}
function M.setup()
local aerial = require("aerial")
local conf = {
backends = { "treesitter", "lsp", "markdown", "man" },
float = {
relative = "win",
override = function(conf)
local padding = 1
conf.anchor = 'NE'
conf.row = padding
conf.col = vim.api.nvim_win_get_width(0) - padding
return conf
end,
},
}
aerial.setup(conf)
end
return M

View file

@ -0,0 +1,23 @@
local g = vim.g
local colors = require('dracula').colors()
vim.cmd[[colorscheme dracula]]
g.rainbow_guifgs = {
colors.red,
colors.orange,
colors.yellow,
colors.green,
colors.purple,
colors.cyan,
colors.pink,
colors.bright_red,
colors.bright_green,
colors.bright_yellow,
colors.bright_blue,
colors.bright_magenta,
colors.bright_cyan
}
g.rainbow_active = 1
--vim.highlight.create('Beacon', {guibg=colors.green, guifg=colors.bg}, false)
vim.api.nvim_set_hl(0, 'Beacon', {bg=colors.green, fg=colors.bg})

View file

@ -0,0 +1,33 @@
local M = {}
local home = os.getenv('HOME')
function scandir(directory)
local i, t, popen = 0, {}, io.popen
local pfile = popen('ls "'..directory..'"')
for filename in pfile:lines() do
i = i + 1
t[i] = filename
end
pfile:close()
return t
end
function M()
catTable = scandir(vim.fn.stdpath('config') .. '/static/')
math.random()
math.randomseed(os.time()+math.random())
math.random(); math.random(); math.random();
file = vim.fn.stdpath('config') .. '/static/' .. catTable[math.random(#catTable)]
local fheight = io.popen('cat '..file..' | wc -l')
local fwidth = io.popen('awk "{print length}" '..file..' | sort -nr | head -1')
local db = require 'dashboard'
db.preview_command = 'cat | lolcat -F 0.3 -p 15'
db.preview_file_path = file
db.preview_file_height = tonumber(fheight:read("*a"))
db.preview_file_width = tonumber(fwidth:read("*a"))
db.header_pad = 0
end
return M()

View file

@ -0,0 +1,80 @@
local M = {}
function M.setup()
local dracula = require("dracula")
--dracula.setup({
-- customize dracula color palette
local conf = {
-- Default dracula colors
-- colors = {
-- bg = "#282A36",
-- fg = "#F8F8F2",
-- selection = "#44475A",
-- comment = "#6272A4",
-- red = "#FF5555",
-- orange = "#FFB86C",
-- yellow = "#F1FA8C",
-- green = "#50fa7b",
-- purple = "#BD93F9",
-- cyan = "#8BE9FD",
-- pink = "#FF79C6",
-- bright_red = "#FF6E6E",
-- bright_green = "#69FF94",
-- bright_yellow = "#FFFFA5",
-- bright_blue = "#D6ACFF",
-- bright_magenta = "#FF92DF",
-- bright_cyan = "#A4FFFF",
-- bright_white = "#FFFFFF",
-- menu = "#21222C",
-- visual = "#3E4452",
-- gutter_fg = "#4B5263",
-- nontext = "#3B4048",
-- },
-- Dracula PRO
colors = {
bg = "#393649",
fg = "#F8F8F2",
selection = "#454158", --prof = #454158
comment = "#6272A4", --pro = #7970A9
red = "#FF9580",
orange = "#FFCA80",
yellow = "#FFFF80",
green = "#8AFF80",
purple = "#9580FF",
cyan = "#80FFEA",
pink = "#FF80BF",
bright_red = "#FF6E6E",
bright_green = "#69FF94",
bright_yellow = "#FFFFA5",
bright_blue = "#D6ACFF",
bright_magenta = "#FF92DF",
bright_cyan = "#A4FFFF",
bright_white = "#FFFFFF",
menu = "#21222C",
visual = "#3E4452",
gutter_fg = "#4B5263",
nontext = "#3B4048",
},
-- show the '~' characters after the end of buffers
show_end_of_buffer = true, -- default false
-- use transparent background
transparent_bg = true, -- default false
-- set custom lualine background color
lualine_bg_color = "#44475a", -- default nil
-- set italic comment
italic_comment = true, -- default false
-- overrides the default highlights see `:h synIDattr`
overrides = {
-- Examples
-- NonText = { fg = dracula.colors().white }, -- set NonText fg to white
-- NvimTreeIndentMarker = { link = "NonText" }, -- link to NonText highlight
-- Nothing = {} -- clear highlight of Nothing
},
}
dracula.setup(conf)
end
-- to use colors in other places
-- local colors = require('dracula').colors()
return M

View file

@ -0,0 +1,17 @@
local M = {}
function M.setup()
local lualine = require 'lualine'
local conf = {
options = {
icons_enabled = true,
theme = 'dracula-nvim',
},
sections = {
lualine_x = {"aerial"},
}
}
lualine.setup(conf)
end
return M

View file

@ -0,0 +1,46 @@
-- require("nvim-tree").setup({
-- disable_netrw = true,
-- hijack_netrw = true,
-- sort_by = "case_sensitive",
-- view = {
-- adaptive_size = true,
-- mappings = {
-- list = {
-- { key = "u", action = "dir_up" },
-- },
-- },
-- },
-- renderer = {
-- group_empty = true,
-- },
-- filters = {
-- dotfiles = false,
-- },
-- })
local M = {}
function M.setup()
local ntree = require 'nvim-tree'
local conf = {
disable_netrw = true,
hijack_netrw = true,
sort_by = "case_sensitive",
view = {
adaptive_size = true,
mappings = {
list = {
{ key = "u", action = "dir_up" },
},
},
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = false,
},
}
ntree.setup(conf)
end
return M

View file

@ -0,0 +1,61 @@
local M = {}
function M.setup()
local colors = require('dracula').colors()
local sitter = require("nvim-treesitter.configs")
local conf = {
ensure_installed = "all",
sync_install = false,
ignore_install = {""},
matchup = {
enable = true,
disable_virtual_text = true,
},
highlight = {
enable = true,
disable = {},
additional_vim_regex_highlighting = true,
},
autopairs = {
enable = true,
},
indent = {
enable = true,
--disable = {
--"python",
--"css"
--}
--
},
audotag = {
enable = true,
disable = {
"xml",
"markdown",
},
},
rainbow = {
enable = true,
extended_mode = false,
colors = {
colors.red,
colors.orange,
colors.yellow,
colors.green,
colors.purple,
colors.cyan,
colors.pink,
colors.bright_red,
colors.bright_green,
colors.bright_yellow,
colors.bright_blue,
colors.bright_magenta,
colors.bright_cyan
},
},
}
sitter.setup(conf)
end
return M

View file

@ -0,0 +1,63 @@
local M = {}
function M.setup()
local whichkey = require "which-key"
local conf = {
window = {
border = "single", -- none, single, double, shadow
position = "bottom", -- bottom, top
},
}
local opts = {
mode = "n", -- Normal mode
prefix = "<leader>",
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
noremap = true, -- use `noremap` when creating keymaps
nowait = false, -- use `nowait` when creating keymaps
}
local mappings = {
["w"] = { "<cmd>update!<CR>", "Save" },
["q"] = { "<cmd>q!<CR>", "Quit" },
["e"] = { "<cmd>NvimTreeToggle<CR>", "Nvim Tree"},
["a"] = { "<cmd>AerialToggle! float<CR>","Aerial Toggle"},
o = {
name = "+open",
},
b = {
name = "Buffer",
c = { "<Cmd>bd!<Cr>", "Close current buffer" },
D = { "<Cmd>%bd|e#|bd#<Cr>", "Delete all buffers" },
},
z = {
name = "Packer",
c = { "<cmd>PackerCompile<cr>", "Compile" },
i = { "<cmd>PackerInstall<cr>", "Install" },
s = { "<cmd>PackerSync<cr>", "Sync" },
S = { "<cmd>PackerStatus<cr>", "Status" },
u = { "<cmd>PackerUpdate<cr>", "Update" },
},
g = {
name = "Git",
s = { "<cmd>Neogit<CR>", "Status" },
},
v = {
name = "Visual",
r = { "<cmd>RainbowToggle<cr>", "Rainbow Brackets Toggle"},
},
}
whichkey.setup(conf)
whichkey.register(mappings, opts)
end
return M

View file

@ -0,0 +1,20 @@
local M = {}
function M.setup()
local winshift = require("winshift")
local conf = {
conf = {
highlight_moving_win = true, --hl window when being moved
focused_hl_group = "Visual", -- hl group for moving window
moving_win_options = {
wrap = false,
cursorline = false,
cusorcolumn = false,
colorcolumn = "",
}
}
}
winshift.setup(conf)
end
return M

153
nvim/lua/diag.lua Normal file
View file

@ -0,0 +1,153 @@
-- Echoing of LSP diagnostics in the commandline.
local M = {}
-- Location information about the last message printed. The format is
-- `(did print, buffer number, line number)`.
local last_echo = { false, -1, -1 }
-- The timer used for displaying a diagnostic in the commandline.
local echo_timer = nil
-- The timer after which to display a diagnostic in the commandline.
local echo_timeout = 250
-- The highlight group to use for warning messages.
local warning_hlgroup = 'WarningMsg'
-- The highlight group to use for error messages.
local error_hlgroup = 'ErrorMsg'
-- If the first diagnostic line has fewer than this many characters, also add
-- the second line to it.
local short_line_limit = 20
-- Shows the current line's diagnostics in a floating window.
function M.show_line_diagnostics()
vim
.lsp
.diagnostic
.show_line_diagnostics({ severity_limit = 'Warning' }, vim.fn.bufnr(''))
end
-- Prints the first diagnostic for the current line.
function M.echo_diagnostic()
if echo_timer then
echo_timer:stop()
end
echo_timer = vim.defer_fn(
function()
local line = vim.fn.line('.') - 1
local bufnr = vim.api.nvim_win_get_buf(0)
if last_echo[1] and last_echo[2] == bufnr and last_echo[3] == line then
return
end
local diags = vim
.lsp
.diagnostic
.get_line_diagnostics(bufnf, line, { severity_limit = 'Warning' })
if #diags == 0 then
-- If we previously echo'd a message, clear it out by echoing an empty
-- message.
if last_echo[1] then
last_echo = { false, -1, -1 }
vim.api.nvim_command('echo ""')
end
return
end
last_echo = { true, bufnr, line }
local diag = diags[1]
local width = vim.api.nvim_get_option('columns') - 15
local lines = vim.split(diag.message, "\n")
local message = lines[1]
local trimmed = false
if #lines > 1 and #message <= short_line_limit then
message = message .. ' ' .. lines[2]
end
if width > 0 and #message >= width then
message = message:sub(1, width) .. '...'
end
local kind = 'warning'
local hlgroup = warning_hlgroup
if diag.severity == vim.lsp.protocol.DiagnosticSeverity.Error then
kind = 'error'
hlgroup = error_hlgroup
end
local chunks = {
{ kind .. ': ', hlgroup },
{ message }
}
vim.api.nvim_echo(chunks, false, {})
end,
echo_timeout
)
end
return M

22
nvim/lua/key_bindings.lua Normal file
View file

@ -0,0 +1,22 @@
local keymap = vim.api.nvim_set_keymap
local default_opts = { noremap = true, silent = true }
local expr_opts = { noremap = true, expr = true, silent = true }
-- Better escape using jk in insert and terminal mode
keymap("i", "jk", "<ESC>", default_opts)
keymap("t", "jk", "<C-\\><C-n>", default_opts)
-- Center search results
keymap("n", "n", "nzz", default_opts)
keymap("n", "N", "Nzz", default_opts)
-- Paste over currently selected text without yanking it
keymap("v", "p", '"_dP', default_opts)
-- Cancel search highlighting with ESC
keymap("n", "<ESC>", ":nohlsearch<Bar>:echo<CR>", default_opts)
-- Move selected line / block of text in visual mode
keymap("x", "K", ":move '<-2<CR>gv-gv", default_opts)
keymap("x", "J", ":move '>+1<CR>gv-gv", default_opts)
-- Resizing panes
keymap("n", "<S-Left>", ":vertical resize +1<CR>", default_opts)
keymap("n", "<S-Right>", ":vertical resize -1<CR>", default_opts)
keymap("n", "<S-Up>", ":resize -1<CR>", default_opts)
keymap("n", "<S-Down>", ":resize +1<CR>", default_opts)

148
nvim/lua/plugins.lua Normal file
View file

@ -0,0 +1,148 @@
local M = {}
function M.setup()
-- Indicate first time installation
local packer_bootstrap = false
-- packer.nvim configuration
--
local conf = {
display = {
open_fn = function()
return require("packer.util").float { border = "rounded" }
end,
},
}
-- Check if packer.nvim is installed
-- Run PackerCompile if there are changes in this file
local function packer_init()
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.cmd [[packadd packer.nvim]]
end
vim.cmd "autocmd BufWritePost plugins.lua source <afile> | PackerCompile"
end
-- Plugins
local function plugins(use)
use { "wbthomason/packer.nvim" }
-- rainbow brackets
use { 'frazrepo/vim-rainbow' }
use { "p00f/nvim-ts-rainbow" }
use { "tpope/vim-surround" }
use { "danilamihailov/beacon.nvim" }
use {
'VonHeikemen/lsp-zero.nvim',
requires = {
-- LSP Support
{'neovim/nvim-lspconfig'},
{'williamboman/mason.nvim'},
{'williamboman/mason-lspconfig.nvim'},
-- Autocompletion
{'hrsh7th/nvim-cmp'},
{'hrsh7th/cmp-buffer'},
{'hrsh7th/cmp-path'},
{'saadparwaiz1/cmp_luasnip'},
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/cmp-nvim-lua'},
-- Snippets
{'L3MON4D3/LuaSnip'},
{'rafamadriz/friendly-snippets'},
}
}
use {
'nvim-treesitter/nvim-treesitter',
run = function()
require('nvim-treesitter.install').update({ with_sync = true })
end,
config = function()
require('config.nvim-treesitter').setup()
end,
}
use {
'stevearc/aerial.nvim',
}
use {
'sindrets/winshift.nvim',
config = function()
require('config.winshift').setup()
end,
}
-- Better icons
use {
"kyazdani42/nvim-web-devicons",
module = "nvim-web-devicons",
config = function()
require("nvim-web-devicons").setup { default = true }
end,
}
-- dracula-vim
use {
'Mofiqul/dracula.nvim',
config = function()
require('config.dracula-vim').setup()
end,
}
-- nvim-tree
use {
'kyazdani42/nvim-tree.lua',
config = function()
require('config.nvim-tree').setup()
end,
}
-- lua-line
use {
'nvim-lualine/lualine.nvim',
config = function()
require("config.lualine").setup()
end,
}
-- WhichKey
use {
"folke/which-key.nvim",
config = function()
require("config.whichkey").setup()
end,
}
--dashboard-nvim
use {
'glepnir/dashboard-nvim',
config = function()
require("config.dashboard")
end,
}
-- Bootstrap Neovim
if packer_bootstrap then
print "Restart Neovim required after installation!"
require("packer").sync()
end
end
packer_init()
local packer = require "packer"
packer.init(conf)
packer.startup(plugins)
local lsp = require('lsp-zero')
lsp.preset('recommended')
lsp.nvim_workspace()
lsp.setup{
on_attach = require("aerial").on_attach,
}
end
return M.setup()