Just for Jer-Bear

This commit is contained in:
2024-05-17 16:50:10 -04:00
commit c87c7e53b0
25 changed files with 1444 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
-- Add a buffer bar at the top.
vim.api.nvim_set_var('airline#extensions#tabline#enabled', true)
-- Change the formatter for the tab/buffer bar.
-- Here's a full list of the different formatters:
-- - default
-- - jsformatter
-- - unique_tail
-- - unique_tail_improved
vim.api.nvim_set_var('airline#extensions#tabline#formatter',
'unique_tail_improved')
+15
View File
@@ -0,0 +1,15 @@
-- local chatgpt = require("chatgpt")
-- wk.register({
-- p = {
-- name = "ChatGPT",
-- e = {
-- function()
-- chatgpt.edit_with_instructions()
-- end,
-- "Edit with instructions",
-- },
-- },
-- }, {
-- prefix = "<leader>",
-- mode = "v",
-- })
+156
View File
@@ -0,0 +1,156 @@
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then
return
end
-- Not sure if this just works or needs vscode to be installed. This came from
-- the same place as the snippet below.
require("luasnip/loaders/from_vscode").lazy_load()
-- This function, along with most of the code in this file, was copied from
-- LunarVim/Neovim-from-scratch branch: 05-completion, commit: a0e07fc
-- I'm not 100% sure what it does, it has something to do with "supertab" for
-- snippets, autocomplete, and normal mode.
local check_backspace = function()
local col = vim.fn.col "." - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
end
--   פּ ﯟ   some other good icons
local kind_icons = {
Text = "",
Method = "m",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
Copilot = "",
}
-- find more here: https://www.nerdfonts.com/cheat-sheet
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
-- Specify `cmp.config.disable` if you want to remove the default `<C-y>`
-- mapping.
["<C-y>"] = cmp.config.disable,
["<C-e>"] = cmp.mapping {
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
['<C-x>'] = cmp.mapping(
cmp.mapping.complete({
config = {
sources = cmp.config.sources({
{ name = 'cmp_ai' },
}),
},
}),
{ 'i' }
),
-- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items.
["<CR>"] = cmp.mapping.confirm { select = true },
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons
-- TODO Need to make icons toggleable,
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.menu = ({
copilot = "[Copilot]",
cmp_ai = "[AI]",
nvim_lsp = "[LSP]",
nvim_lua = "[NVIM_LUA]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
},
sources = {
{ name = "copilot" },
-- Uncomment to run on every keystroke.
-- { name = "cmp_ai" },
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "buffer" },
{ name = "path" },
{ name = "luasnip" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
documentation = cmp.config.window.bordered()
},
experimental = {
ghost_text = true,
native_menu = false,
},
}
+58
View File
@@ -0,0 +1,58 @@
function ColorMyPencils(color)
color = color or "base16-gruvbox-dark-hard"
-- color = color or "default"
vim.cmd.colorscheme(color)
vim.api.nvim_set_hl(0, "Normal", { ctermbg="none" })
vim.api.nvim_set_hl(0, "NormalFloat", { link="Normal" })
vim.api.nvim_set_hl(0, "NonText", { link="Normal" })
vim.api.nvim_set_hl(0, "LineNr", { link="Normal" })
vim.api.nvim_set_hl(0, "SignColumn", { link="Normal" })
vim.api.nvim_set_hl(0, "Visual", { ctermfg=0, ctermbg=3 })
vim.api.nvim_set_hl(0, "Search", { ctermfg=4, ctermbg=3 })
vim.api.nvim_set_hl(0, "Folded", { ctermfg=2, ctermbg=0 })
-- diff colors
-- The one issue with this is you won't be as easy to tell where the diff
-- sections are if there is no transparency in the terminal.
vim.api.nvim_set_hl(0, "DiffAdd", { ctermfg=2, ctermbg=0 })
vim.api.nvim_set_hl(0, "DiffDelete", { ctermfg=1, ctermbg=0 })
vim.api.nvim_set_hl(0, "DiffChange", { ctermfg=8, ctermbg=0 })
vim.api.nvim_set_hl(0, "DiffText", { ctermfg=3, ctermbg=0 })
-- Popup menu
vim.api.nvim_set_hl(0, "Pmenu", { ctermfg=7, ctermbg=0 })
vim.api.nvim_set_hl(0, "PmenuSel", { ctermfg=0, ctermbg=8 })
-- Current line highlight and line wrap column.
vim.opt.colorcolumn = '-0'
vim.opt.cursorline = true
vim.api.nvim_set_hl(0, "ColorColumn", { ctermbg=0 })
vim.api.nvim_set_hl(0, "CursorLine",
{ ctermbg=0, underline=false })
vim.api.nvim_set_hl(0, "CursorLineNr",
{ ctermbg="none", underline=false })
vim.api.nvim_set_hl(0, "CursorLineSign",
{ ctermbg="none", underline=false })
-- Other stuff
vim.api.nvim_set_hl(0, "WinSeparator",
{ ctermfg = 3, ctermbg = "none" })
vim.api.nvim_set_hl(0, "SpellBad",
{ cterm = { undercurl = true }, ctermfg = 1, ctermbg = 0 })
-- GitSigns colors
--
-- TODO this should be moved to gitsigns.lua
-- It would have been nice to link these to 'DiffAdd', 'DiffChange', and
-- 'DiffDelete', but currently this has a transparent background, while the
-- others don't. This may change though so keep the possibility of linking
-- in mind.
vim.api.nvim_set_hl(0, "GitSignsAdd", { ctermfg=2, ctermbg="none" })
vim.api.nvim_set_hl(0, "GitSignsChange", { ctermfg=3, ctermbg="none" })
vim.api.nvim_set_hl(0, "GitSignsDelete", { ctermfg=1, ctermbg="none" })
end
ColorMyPencils()
+2
View File
@@ -0,0 +1,2 @@
vim.api.nvim_set_keymap('n', 'ga', "<Plug>(EasyAlign)", { noremap = true, silent = true });
vim.api.nvim_set_keymap('x', 'ga', "<Plug>(EasyAlign)", { noremap = true, silent = true });
+43
View File
@@ -0,0 +1,43 @@
require('gitsigns').setup{
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end)
return '<Ignore>'
end, {expr=true})
map('n', '[c', function()
if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>'
end, {expr=true})
-- Actions
map('n', '<leader>hs', gs.stage_hunk)
map('n', '<leader>hr', gs.reset_hunk)
map('v', '<leader>hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
map('v', '<leader>hr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
map('n', '<leader>hS', gs.stage_buffer)
map('n', '<leader>hu', gs.undo_stage_hunk)
map('n', '<leader>hR', gs.reset_buffer)
map('n', '<leader>hp', gs.preview_hunk)
map('n', '<leader>hb', function() gs.blame_line{full=true} end)
map('n', '<leader>tb', gs.toggle_current_line_blame)
map('n', '<leader>hd', gs.diffthis)
map('n', '<leader>hD', function() gs.diffthis('~') end)
-- Commented out because we use this binding for trouble.
-- map('n', '<leader>td', gs.toggle_deleted)
-- Text object
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end
}
+6
View File
@@ -0,0 +1,6 @@
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
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>fs', builtin.lsp_document_symbols, {})
+80
View File
@@ -0,0 +1,80 @@
-- TODO Here are some ways to run this plugin just on the current file.
-- :exe ":TodoQuickFix cwd=" .. fnameescape(expand("%:p"))
-- :exe ":TodoTrouble cwd=" .. fnameescape(expand("%:p"))
-- TODO Add a way to add TODO REM.
-- TODO Remove unused keywords.
-- TODO REM Most of this was copied from the default config. Instead we should
-- only override the settings we want to change. Maybe put the whole
-- default config in a comment.
-- All settings in this config are the default values from commit 3094ead,
-- unless noted by CHANGE_FROM_DEFAULT.
require("todo-comments").setup {
signs = true, -- show icons in the signs column
sign_priority = 8, -- sign priority
-- keywords recognized as todo comments
keywords = {
FIX = {
icon = "", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below)
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually
},
TODO = { icon = "", color = "info" },
HACK = { icon = "", color = "warning" },
WARN = { icon = "", color = "warning", alt = { "WARNING", "XXX" } },
PERF = { icon = "", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
NOTE = { icon = "", color = "hint", alt = { "INFO" } },
TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
},
gui_style = {
fg = "NONE", -- The gui style to use for the fg highlight group.
bg = "BOLD", -- The gui style to use for the bg highlight group.
},
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
-- highlighting of the line containing the todo comment
-- * before: highlights before the keyword (typically comment characters)
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
after = "fg", -- "fg" or "bg" or empty
-- CHANGE_FROM_DEFAULT: Changed to make the ':' optional.
-- pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
pattern = [[.*<(KEYWORDS)(:| )]], -- pattern or table of patterns, used for highlighting (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
-- list of named colors where we try to extract the guifg from the
-- list of highlight groups or use the hex color if hl not found as a fallback
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" }
},
search = {
command = "rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
-- CHANGE_FROM_DEFAULT: Changed to make the ':' optional.
-- pattern = [[\b(KEYWORDS):]], -- ripgrep regex
pattern = [[\b(KEYWORDS)( |:)]],
},
}
+41
View File
@@ -0,0 +1,41 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
-- ensure_installed = { "bash", "lua", "vim", "vimdoc" },
-- 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,
-- List of parsers to ignore installing (for "all")
-- ignore_install = { "javascript" },
---- 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,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
-- disable = { "c", "rust" },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
-- disable = function(lang, buf)
-- local max_filesize = 100 * 1024 -- 100 KB
-- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
-- if ok and stats and stats.size > max_filesize then
-- return true
-- end
-- end,
-- 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,
},
}
+7
View File
@@ -0,0 +1,7 @@
local opts = { noremap = true, silent = true }
local keymap = function(mode, key, command)
vim.api.nvim_set_keymap(mode, key, command, opts)
end
keymap("n", "<leader>td", ":Trouble document_diagnostics<cr>")
keymap("n", "<leader>tt", ":TroubleToggle<cr>")