Skip to content

Instantly share code, notes, and snippets.

@antonmry
Last active January 6, 2025 19:03
Show Gist options
  • Save antonmry/b292139eed93a2c838c738c5915db0bc to your computer and use it in GitHub Desktop.
Save antonmry/b292139eed93a2c838c738c5915db0bc to your computer and use it in GitHub Desktop.
NeoVim configuration files created on 2025-01-06 20:03:20
--- Name: minimum
--- Description: A minimal colorscheme for neovim.
--- Author: Peter Aronoff
--- License: BSD-3-Clause
--- URL: https://github.com/telemachus/dotfiles/blob/main/config/nvim/colors/minimum.lua
local g = vim.g
local cmd = vim.cmd
if g.colors_name ~= nil then
cmd("highlight clear")
end
g.colors_name = "minimum"
local colors = {
-- Terminal palette in 0-15 order.
-- I took most of these from the following site:
-- https://sashamaps.net/docs/resources/20-colors/
black = "#000000",
dark_red = "#800000",
dark_green = "#194a1f",
dark_yellow = "#808000",
dark_blue = "#000075",
dark_magenta = "#8b008b",
dark_cyan = "#469990",
grey = "#c5c6c8",
dark_grey = "#737373",
red = "#d20f2c",
green = "#3cb44d",
yellow = "#ffe119",
blue = "#4363d8",
magenta = "#f032e6",
cyan = "#42d4f4",
white = "#ffffff",
-- Additional colors
near_black = "#090909",
light_grey = "#f0f1f3",
light_red = "#fabed4",
light_green = "#aaffc3",
light_yellow = "#fffac8",
light_blue = "#d5e5f6",
}
g.terminal_color_0 = colors.black
g.terminal_color_1 = colors.dark_red
g.terminal_color_2 = colors.dark_green
g.terminal_color_3 = colors.dark_yellow
g.terminal_color_4 = colors.dark_blue
g.terminal_color_5 = colors.dark_magenta
g.terminal_color_6 = colors.dark_cyan
g.terminal_color_7 = colors.grey
g.terminal_color_8 = colors.dark_grey
g.terminal_color_9 = colors.red
g.terminal_color_10 = colors.green
g.terminal_color_11 = colors.yellow
g.terminal_color_12 = colors.blue
g.terminal_color_13 = colors.magenta
g.terminal_color_14 = colors.cyan
g.terminal_color_15 = colors.white
local highlight_groups = {
-- Editor (:help highlight-groups)
["ColorColumn"] = { bg = colors.light_grey },
["Conceal"] = { fg = "NONE", bg = "NONE", link = "NONE" },
["CurSearch"] = { link = "Visual" },
["Cursor"] = { fg = "bg", bg = "fg" },
["lCursor"] = { link = "Cursor" },
["CursorIM"] = { link = "Cursor" },
["CursorColumn"] = { link = "ColorColumn" },
["CursorLine"] = { link = "Visual" },
["Directory"] = { bold = true },
["DiffAdd"] = { fg = colors.dark_green, bg = colors.light_green },
["DiffChange"] = { fg = colors.dark_yellow, bg = colors.light_yellow },
["DiffDelete"] = { fg = colors.dark_red, bg = colors.light_red },
["DiffText"] = { link = "DiffChange" },
["EndOfBuffer"] = { fg = colors.dark_grey },
["TermCursor"] = { fg = "bg", bg = "fg" },
["ErrorMsg"] = { fg = colors.red },
["WinSeparator"] = {},
["Folded"] = { fg = colors.near_black },
["FoldColumn"] = { link = "Folded" },
["SignColumn"] = { fg = colors.dark_grey },
["IncSearch"] = { link = "Visual" },
["IncReplace"] = { link = "DiffChange" },
["LineNr"] = { fg = colors.near_black, bold = true },
["LineNrAbove"] = { fg = colors.grey },
["LineNrBelow"] = { link = "LineNrAbove" },
["MatchParen"] = { fg = colors.near_black, bold = true },
["ModeMsg"] = { fg = colors.near_black, bold = true },
["MoreMsg"] = { fg = colors.dark_grey },
["Normal"] = { fg = colors.near_black, bg = colors.white },
["NormalFloat"] = { link = "Normal" },
["NonText"] = { fg = colors.light_grey },
["FloatBorder"] = { fg = colors.near_black },
["FloatTitle"] = { link = "Title" },
["FloatFooter"] = { link = "FloatTitle" },
["Pmenu"] = { fg = colors.near_black, bg = colors.white },
["PmenuSel"] = { link = "Visual" },
["PmenuKind"] = { link = "Pmenu" },
["PmenuKindSel"] = { link = "Visual" },
["PmenuExtra"] = { link = "Pmenu" },
["PmenuExtraSel"] = { link = "Visual" },
["PmenuSbar"] = { link = "Pmenu" },
["PmenuThumb"] = { link = "Pmenu" },
["Question"] = { fg = colors.dark_grey },
["QuickFixLine"] = { link = "Visual" },
["qfFileName"] = { bold = false, link = "NONE" },
["qfLineNr"] = { bold = false, link = "NONE" },
["Search"] = { link = "Visual" },
["SnippetTabstop"] = { link = "Visual" },
["SpecialKey"] = { fg = colors.dark_grey },
["SpellBad"] = { undercurl = true },
["SpellCap"] = { link = "SpellBad" },
["SpellLocal"] = { link = "SpellBad" },
["SpellRare"] = { link = "SpellBad" },
["StatusLine"] = { fg = colors.dark_grey, bg = colors.light_grey },
["StatusLineNC"] = { fg = colors.dark_grey },
["TabLine"] = { fg = colors.near_black, bg = colors.white },
["TabLineFill"] = { bg = colors.dark_grey },
["TabLineSel"] = { link = "StatusLine" },
["Title"] = { bold = true },
["Visual"] = { bg = colors.light_blue, bold = true },
["Whitespace"] = { fg = colors.grey },
["WildMenu"] = { bg = colors.dark_grey, bold = true },
["WinBar"] = { fg = colors.near_black, bg = colors.white, bold = true },
["WinBarNC"] = { fg = colors.near_black, bg = colors.white },
-- Syntax (:help group-name)
["Comment"] = { fg = colors.dark_grey },
["Constant"] = { fg = colors.near_black },
["String"] = { fg = colors.near_black },
["Character"] = { link = "String" },
["Number"] = { fg = colors.near_black },
["Boolean"] = { fg = colors.near_black },
["Float"] = { link = "Number" },
["Identifier"] = { link = "Constant" },
["Function"] = { link = "Constant" },
["Statement"] = { link = "Constant" },
["Conditional"] = { bold = true },
["Repeat"] = { bold = true },
["Label"] = { bold = true },
["Operator"] = { bold = true },
["Keyword"] = { fg = colors.near_black, bold = true },
["Exception"] = { bold = true },
["PreProc"] = { fg = colors.near_black },
["Include"] = { link = "PreProc" },
["Define"] = { link = "PreProc" },
["Macro"] = { link = "PreProc" },
["PreCondit"] = { link = "PreProc" },
["Type"] = { link = "PreProc" },
["StorageClass"] = { link = "Type" },
["Structure"] = { link = "Type" },
["Typedef"] = { link = "Type" },
["Special"] = { fg = colors.near_black },
["SpecialChar"] = { link = "Special" },
["Tag"] = { fg = colors.near_black },
["Delimiter"] = { fg = colors.near_black },
["SpecialComment"] = { link = "Special" },
["Debug"] = { fg = colors.yellow },
["Underlined"] = { underline = true },
["Ignore"] = {},
["Error"] = { fg = colors.red, bold = true },
["Todo"] = { fg = colors.yellow, bold = true },
["Added"] = { fg = colors.dark_yellow },
["Changed"] = { fg = colors.cyan },
["Removed"] = { fg = colors.red },
-- Syntax from language files
["gitcommitSummary"] = { fg = colors.near_black, bold = true },
["gitcommitFirstLine"] = { link = "gitcommitSummary" },
["gitcommitComment"] = { link = "Comment" },
["gitcommitHeader"] = { fg = colors.dark_grey, bold = true },
["gitcommitBranch"] = { link = "gitcommitHeader" },
["gitcommitDiscardedType"] = { fg = colors.dark_grey, bold = false },
["gitcommitDiscardedFile"] = { link = "gitcommitDiscardedType" },
["gitcommitSelectedType"] = { link = "gitcommitDiscardedType" },
["gitcommitSelectedFile"] = { link = "gitcommitDiscardedType" },
["gitcommitUntrackedFile"] = { link = "gitcommitDiscardedType" },
["diffFile"] = { fg = colors.blue },
["diffIndexLine"] = { fg = colors.dark_grey },
["diffLine"] = { link = "diffIndexLine" },
["diffAdded"] = { link = "DiffAdd" },
["diffNewFile"] = { link = "DiffAdd" },
["diffOldFile"] = { link = "DiffChange" },
["diffChanged"] = { link = "DiffChange" },
["diffRemoved"] = { link = "DiffDelete" },
["mailHeader"] = { bold = false },
["mailHeaderKey"] = { link = "mailHeader" },
["mailURL"] = { underline = true },
["mailEmail"] = { link = "mailURL" },
["mailQuoted"] = { link = "Comment" },
["mailQuoted1"] = { link = "mailQuoted" },
["mailQuoted3"] = { link = "mailQuoted" },
["mailQuoted5"] = { link = "mailQuoted" },
["mailQuoted2"] = { fg = colors.blue, bg = colors.white },
["mailQuoted4"] = { link = "mailQuoted2" },
["mailQuoted6"] = { link = "mailQuoted2" },
-- Tree-sitter (:help treesitter-highlight-groups)
["@variable"] = { fg = colors.near_black },
["@variable.builtin"] = { link = "Variable" },
["@variable.parameter"] = { link = "Variable" },
["@variable.parameter.builtin"] = { link = "Variable" },
["@variable.member"] = { link = "Variable" },
["@constant"] = { link = "Variable" },
["@constant.builtin"] = { link = "Variable" },
["@constant.macro"] = { link = "Variable" },
["@module"] = { fg = colors.near_black, bold = true },
["@module.builtin"] = { link = "@module" },
["@label"] = { link = "@module" },
["@string"] = { link = "String" },
["@string.documentation"] = { link = "Comment" },
["@string.regexp"] = { link = "String" },
["@string.escape"] = { link = "String" },
["@string.special"] = { link = "String" },
["@string.special.symbol"] = { link = "String" },
["@string.special.path"] = { link = "String" },
["@string.special.url"] = { link = "String" },
["@character"] = { link = "String" },
["@character.special"] = { link = "String" },
["@boolean"] = { link = "Boolean" },
["@number"] = { link = "Number" },
["@number.float"] = { link = "Float" },
["@type"] = { link = "Type" },
["@type.builtin"] = { link = "Type" },
["@type.definition"] = { link = "Type" },
["@attribute"] = { link = "Type" },
["@attribute.builtin"] = { link = "Type" },
["@property"] = { link = "Type" },
["@function"] = { link = "Function" },
["@function.builtin"] = { link = "Function" },
["@function.call"] = { link = "Function" },
["@function.macro"] = { link = "Function" },
["@function.method"] = { link = "Function" },
["@function.method.call"] = { link = "Function" },
["@constructor"] = { link = "Function" },
["@operator"] = { link = "Operator" },
["@keyword"] = { link = "Keyword" },
["@keyword.coroutine"] = { link = "Keyword" },
["@keyword.function"] = { link = "Keyword" },
["@keyword.operator"] = { link = "Keyword" },
["@keyword.import"] = { link = "Keyword" },
["@keyword.type"] = { link = "Keyword" },
["@keyword.modifier"] = { link = "Keyword" },
["@keyword.repeat"] = { link = "Keyword" },
["@keyword.return"] = { link = "Keyword" },
["@keyword.debug"] = { link = "Keyword" },
["@keyword.exception"] = { link = "Keyword" },
["@keyword.conditional"] = { link = "Keyword" },
["@keyword.conditional.ternary"] = { link = "Keyword" },
["@keyword.directive"] = { link = "Keyword" },
["@keyword.directive.define"] = { link = "Keyword" },
["@punctuation.delimiter"] = { link = "Delimiter" },
["@punctuation.bracket"] = { link = "Delimiter" },
["@punctuation.special"] = { link = "Delimiter" },
["@comment"] = { link = "Comment" },
["@comment.documentation"] = { link = "Comment" },
["@comment.error"] = { fg = colors.dark_grey, bg = colors.yellow },
["@comment.warning"] = { link = "@comment.error" },
["@comment.todo"] = { fg = colors.dark_grey, bg = colors.light_yellow },
["@comment.note"] = { link = "@comment.todo" },
["@markup.strong"] = { bold = true },
["@markup.italic"] = { italic = true },
["@markup.strikethrough"] = { strikethrough = true },
["@markup.underline"] = { underline = true },
["@markup.heading"] = { fg = colors.near_black, bold = true },
["@markup.heading.1"] = { link = "@markup.heading" },
["@markup.heading.2"] = { link = "@markup.heading" },
["@markup.heading.3"] = { link = "@markup.heading" },
["@markup.heading.4"] = { link = "@markup.heading" },
["@markup.heading.5"] = { link = "@markup.heading" },
["@markup.heading.6"] = { link = "@markup.heading" },
["@markup.quote"] = { link = "Comment" },
["@markup.math"] = { fg = colors.near_black },
["@markup.link"] = { underline = true },
["@markup.link.label"] = { link = "@markup.link" },
["@markup.link.url"] = { link = "@markup.link" },
["@markup.raw"] = { fg = colors.dark_grey },
["@markup.raw.block"] = { fg = colors.dark_grey },
["@markup.list"] = { fg = colors.near_black },
["@markup.list.checked"] = { link = "@markup.list" },
["@markup.list.unchecked"] = { link = "@markup.list" },
["@diff.plus"] = { link = "DiffAdd" },
["@diff.minus"] = { link = "DiffDelete" },
["@diff.delta"] = { link = "DiffChange" },
["@tag"] = { fg = colors.dark_grey },
["@tag.builtin"] = { fg = colors.dark_grey },
["@tag.attribute"] = { fg = colors.dark_grey },
["@tag.delimiter"] = { fg = colors.dark_grey },
-- Diagnostics (:help diagnostic-highlights)
["DiagnosticError"] = { fg = colors.dark_red, bg = colors.light_red },
["DiagnosticWarn"] = { fg = colors.dark_yellow, bg = colors.light_yellow },
["DiagnosticInfo"] = { fg = colors.dark_green, bg = colors.light_green },
["DiagnosticHint"] = { fg = colors.dark_blue, bg = colors.light_blue },
["DiagnosticOk"] = { link = "NONE" },
["DiagnosticVirtualTextError"] = { link = "DiagnosticError" },
["DiagnosticVirtualTextWarn"] = { link = "DiagnosticWarn" },
["DiagnosticVirtualTextInfo"] = { link = "DiagnosticInfo" },
["DiagnosticVirtualTextHint"] = { link = "DiagnosticHint" },
["DiagnosticVirtualTextOk"] = { link = "DiagnosticOk" },
["DiagnosticUnderlineError"] = { link = "NONE" },
["DiagnosticUnderlineWarn"] = { link = "NONE" },
["DiagnosticUnderlineInfo"] = { link = "NONE" },
["DiagnosticUnderlineHint"] = { link = "NONE" },
["DiagnosticUnderlineOk"] = { link = "NONE" },
["DiagnosticFloatingError"] = { link = "DiagnosticError" },
["DiagnosticFloatingWarn"] = { link = "DiagnosticWarn" },
["DiagnosticFloatingInfo"] = { link = "DiagnosticInfo" },
["DiagnosticFloatingHint"] = { link = "DiagnosticHint" },
["DiagnosticFloatingOk"] = { link = "DiagnosticOk" },
["DiagnosticSignError"] = { link = "DiagnosticError" },
["DiagnosticSignWarn"] = { link = "DiagnosticWarn" },
["DiagnosticSignInfo"] = { link = "DiagnosticInfo" },
["DiagnosticSignHint"] = { link = "DiagnosticHint" },
["DiagnosticSignOk"] = { link = "DiagnosticOk" },
["DiagnosticDeprecated"] = { strikethrough = true, sp = colors.red },
["DiagnosticUnnecessary"] = { fg = colors.dark_grey },
-- Plugins
--
-- indent-blankline.nvim
-- https://github.com/lukas-reineke/indent-blankline.nvim
["IblIndent"] = { fg = colors.grey },
["IblWhitespace"] = { link = "IblIndent" },
["IblScope"] = { fg = colors.near_black },
-- oil.nvim
-- https://github.com/stevearc/oil.nvim
["OilDir"] = { fg = colors.blue },
}
local highlight = vim.api.nvim_set_hl
for group, attributes in pairs(highlight_groups) do
highlight(0, group, attributes)
end
-- Check if the current compiler is already set
if vim.g.current_compiler then
return
end
-- Set the current compiler to gradle
vim.g.current_compiler = "gradle"
-- Set the makeprg option to gradle
vim.opt.makeprg = "gradle"
-- Set the errorformat option
vim.opt.errorformat = table.concat({
"%E[ant:scalac] %f:%l: error: %m",
"%W[ant:scalac] %f:%l: warning: %m",
"%E%.%#:compile%\\w%#Java%f:%l: error: %m,%-Z%p^,%-C%.%#",
"%W%.%#:compile%\\w%#Java%f:%l: warning: %m,%-Z%p^,%-C%.%#",
"%E%f:%l: error: %m,%-Z%p^,%-C%.%#",
"%W%f:%l: warning: %m,%-Z%p^,%-C%.%#",
"%E%f: %\\d%\\+: %m @ line %l, column %c.,%-C%.%#,%Z%p^",
"%E%>%f: %\\d%\\+: %m,%C @ line %l, column %c.,%-C%.%#,%Z%p^",
"%-G%.%#"
}, ",")
if vim.g.current_compiler then
return
end
vim.g.current_compiler = "gradlew"
vim.o.makeprg = "./gradlew"
vim.o.errorformat = table.concat({
"%E[ant:scalac] %f:%l: error: %m",
"%W[ant:scalac] %f:%l: warning: %m",
"%E%.%#:compile%\\w%#Java%f:%l: error: %m,%-Z%p^,%-C%.%#",
"%W%.%#:compile%\\w%#Java%f:%l: warning: %m,%-Z%p^,%-C%.%#",
"%E%f:%l: error: %m,%-Z%p^,%-C%.%#",
"%W%f:%l: warning: %m,%-Z%p^,%-C%.%#",
"%E%f: %\\d%\\+: %m @ line %l, column %c.,%-C%.%#,%Z%p^",
"%E%>%f: %\\d%\\+: %m,%C @ line %l, column %c.,%-C%.%#,%Z%p^",
"%-G%.%#"
}, ",")
-- Lua Compiler File
-- Compiler: maven
if vim.g.current_compiler then
return
end
vim.g.current_compiler = "maven"
vim.o.makeprg = "mvn"
vim.o.errorformat = table.concat({
"%-G[INFO] %.%#",
"%-G[debug] %.%#",
"[FATAL] Non-parseable POM %f: %m%\\s%\\+@%.%#line %l\\, column %c%.%#",
"[%tRROR] Malformed POM %f: %m%\\s%\\+@%.%#line %l\\, column %c%.%#",
"[%tARNING] %f:[%l\\,%c] %m",
"[%tRROR] %f:[%l\\,%c] %m",
"%+E%>[ERROR] %.%\\+Time elapsed:%.%\\+<<< FAILURE!",
"%+E%>[ERROR] %.%\\+Time elapsed:%.%\\+<<< ERROR!",
"%+Z%\\s%#at %f(%\\f%\\+:%l)",
"%+C%.%#"
}, ",")
-- Additional settings or configurations can be added here if needed
-- brew install google-java-format
-- Formatter
require("conform").formatters_by_ft.java = { "google-java-format" }
-- Linter: checkstype? Spotbugs?
--require("lint").linters_by_ft.java = { "" }
-- brew install jq cspell
-- Formatter
require("conform").formatters_by_ft.json = { "jq" }
-- Linter
require("lint").linters_by_ft.json = { "cspell" }
-- brew install jq cspell
-- Formatter
require("conform").formatters_by_ft.json = { "jq" }
-- Linter
require("lint").linters_by_ft.json = { "cspell" }
-- brew install stylua
-- Formatter
require("conform").formatters_by_ft.lua = { "stylua" }
-- Linter
require("lint").linters_by_ft.lua = { "luac" }
-- brew install vale deno_fmt
-- Formatter
require("conform").formatters_by_ft.markdown = { "deno_fmt" }
-- Linter
require("lint").linters_by_ft.markdown = { "vale" }
-- brew install rust-analyzer
-- Formatter
require("conform").formatters_by_ft.rust = { "rustfmt" }
-- Linter
require("lint").linters_by_ft.rust = { "clippy" }
-- Auto-completion
-- See https://f1sty.github.io/neovim/nvim/lsp/language-server/config/dotfiles/completion/2023/09/10/simple-nvim-lsp-setup.html
vim.lsp.start({
name = 'rust-analyzer',
cmd = {'rust-analyzer'},
root_dir = vim.fs.dirname(vim.fs.find({'Cargo.toml', 'main.rs'}, { upward = true })[1]),
})
-- cargo install shellharden
-- Formatter
require("conform").formatters_by_ft.sh = { "shellharden" }
-- Linter
--require("lint").linters_by_ft.sh = { "TODO" }
-- brew install sqlfluff
-- Formatter
local conform = require("conform")
-- Custom for duckdb
conform.formatters.duckdb = {
command = "sqlfluff",
args = {
"fix",
"--dialect",
"duckdb",
"--disable-progress-bar",
"-n",
"-",
},
stdin = true,
}
conform.formatters_by_ft.sql = { "duckdb" }
-- Linter
local lint = require("lint")
local sqlfluff = lint.linters.sqlfluff
sqlfluff.args = {
"lint",
"--format=json",
"--dialect=duckdb",
}
lint.linters_by_ft = {
sql = { "sqlfluff" },
}
-- brew install yamllint yamlfmt
-- Formatter
require("conform").formatters_by_ft.yaml = { "yamlfmt" }
-- Linter
require("lint").linters_by_ft.yaml = { "yamlfmt" }
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not 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)
----------------
--- plugins ---
----------------
require("lazy").setup({
-- Default linter
{
"mfussenegger/nvim-lint",
},
-- Default formatter
{
"stevearc/conform.nvim",
config = function()
require("conform").setup({
log_level = vim.log.levels.WARN,
notify_on_error = true,
notify_no_formatters = true,
})
end,
},
-- Default tags
{
"preservim/tagbar",
},
-- Commenting out lines with gcc
{
"tpope/vim-commentary",
},
-- Show pairs
{
"windwp/nvim-autopairs",
config = function()
require("nvim-autopairs").setup({
check_ts = true,
})
end,
},
-- Fuzzy finder (instead of telescope)
{
"ibhagwan/fzf-lua",
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
-- calling `setup` is optional for customization
require("fzf-lua").setup({})
end,
},
-- File browser
{
"stevearc/oil.nvim",
opts = {},
},
-- Execute text in the terminal
{
"jpalardy/vim-slime",
config = function()
vim.g.slime_target = "tmux"
vim.g.slime_default_config = {
socket_name = "default",
target_pane = "{last}",
}
end,
},
-- Copilot integration
{
"CopilotC-Nvim/CopilotChat.nvim",
branch = "main",
dependencies = {
{ "github/copilot.vim" },
{ "nvim-lua/plenary.nvim" }, -- for curl, log wrapper
},
opts = {
context = "git, files",
debug = true,
show_help = false,
mappings = {
complete = {
insert = "",
},
},
window = {
layout = "float",
width = 0.7,
height = 0.9,
},
highlight_headers = false,
separator = "---",
error_header = "> [!ERROR] Error",
},
},
{ -- https://github.com/antonmry/diff_copilot.nvim
"diff_copilot.nvim",
dir = "~/.config/nvim/local/diff_copilot.nvim",
config = true,
},
-- Chezmoi integration
{
"xvzc/chezmoi.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("chezmoi").setup({
edit = {
watch = true,
force = false,
},
notification = {
on_open = true,
on_apply = true,
on_watch = true,
},
})
end,
},
-- RUST: do I need it?
-- {
-- "rust-lang/rust.vim",
-- },
})
----------------
--- SETTINGS ---
----------------
-- disable netrw at the very start of our init.lua, because we use Oil
-- vim.g.loaded_netrw = 1
-- vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true -- Enable 24-bit RGB colors
vim.cmd("colorscheme minimum")
vim.opt.colorcolumn = "81" -- sets the columns at which to display a color marker.
vim.opt.number = true -- Show line numbers
vim.opt.showmatch = true -- Highlight matching parenthesis
vim.opt.splitright = true -- Split windows right to the current windows
vim.opt.splitbelow = true -- Split windows below to the current windows
vim.opt.autowrite = true -- Automatically save before :next, :make etc.
vim.opt.swapfile = false -- Don't use swapfile
vim.opt.ignorecase = true -- Search case insensitive...
vim.opt.smartcase = true -- ... but not it begins with upper case
vim.opt.completeopt = "menuone,noinsert,preview" -- Autocomplete options
vim.opt.showbreak = "↪" -- sets the string to be shown in front of lines that are wrapped
vim.opt.listchars = "tab:→\\ ,nbsp:␣,trail:•,extends:⟩,precedes:⟨" -- sets the characters for displaying tabs and trailing spaces.
vim.opt.list = true -- enables the display of the `listchars`.
vim.opt.undofile = true
vim.opt.undodir = vim.fn.stdpath("data") .. "undo"
-- Disable status bar
vim.opt.ruler = false
vim.opt.laststatus = 0
vim.opt.showcmd = false
vim.opt.cmdheight = 1
-- Indent Settings
vim.opt.autoindent = true -- copy indent from current line when starting a new line
vim.opt.wrap = true
vim.opt.tabstop = 8
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
-- Spell checking
vim.opt.spelllang = "en_us"
vim.opt.spell = true
-- the following show handler will show the most recent diagnostics
-- https://neovim.io/doc/user/diagnostic.html#diagnostic-loclist-example
vim.diagnostic.handlers.loclist = {
show = function(_, _, _, opts)
-- Generally don't want it to open on every update
opts.loclist.open = opts.loclist.open or false
local winid = vim.api.nvim_get_current_win()
vim.diagnostic.setloclist(opts.loclist)
vim.api.nvim_set_current_win(winid)
end,
}
vim.diagnostic.config({
underline = true,
signs = true,
virtual_text = false,
float = {
show_header = true,
source = "if_many",
focusable = false,
},
-- Open the location list on every diagnostic change (warnings/errors only).
loclist = {
open = true,
severity = { min = vim.diagnostic.severity.HINT },
},
})
-----------------
--- KEYMAPS -----
-----------------
-- This comes first, because we have mappings that depend on leader
vim.g.mapleader = " "
-- Exit on jj and jk
vim.keymap.set("n", "j", "gj")
vim.keymap.set("n", "k", "gk")
vim.keymap.set("n", "<leader>g", "<cmd>lua require('fzf-lua').live_grep()<CR>", { silent = true })
vim.keymap.set("n", "<leader>n", "<cmd>lua require('fzf-lua').files()<CR>", { silent = true })
vim.keymap.set("n", "<leader>h", "<cmd>lua require('fzf-lua').command_history()<CR>", { silent = true })
vim.keymap.set("", "<leader>f", function()
require("conform").format({ async = true }, function(err)
if not err then
local mode = vim.api.nvim_get_mode().mode
if vim.startswith(string.lower(mode), "v") then
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
end
end
end)
end, { desc = "Format code" })
vim.keymap.set("n", "<leader>l", function()
require("lint").try_lint()
end, { desc = "Trigger linting for current file" })
vim.keymap.set("n", "<leader>c", function()
vim.cmd("CopilotChatOpen")
end, { desc = "Open CopilotChat" })
vim.keymap.set("n", "<leader>ca", function()
local actions = require("CopilotChat.actions")
require("CopilotChat.integrations.fzflua").pick(actions.prompt_actions())
end, { desc = "CopilotChat - Prompt actions" })
vim.keymap.set("n", "<leader>cc", function()
vim.cmd("DiffCopilot")
end, { desc = "Open Diff Copilot" })
-----------------
--- EXPLORER ----
-----------------
require("oil").setup({
default_file_explorer = true,
delete_to_trash = true,
skip_confirm_for_simple_edits = false,
prompt_save_on_select_new_entry = true,
-- Set to true to watch the filesystem for changes and reload oil
watch_for_changes = false,
view_options = {
-- Show files and directories that start with "."
show_hidden = true,
-- This function defines what is considered a "hidden" file
is_hidden_file = function(name, bufnr)
local m = name:match("^%.")
return m ~= nil
end,
is_always_hidden = function(name, bufnr)
return false
end,
},
})
----------------
--- COPILOT ---
----------------
vim.api.nvim_create_user_command("CopilotChatActions", function()
require("CopilotChat.integrations.fzflua").pick(actions.prompt_actions())
end, {})
vim.api.nvim_del_user_command("CopilotChatCommit")
vim.api.nvim_del_user_command("CopilotChatCommitStaged")
vim.api.nvim_del_user_command("CopilotChatDocs")
vim.api.nvim_del_user_command("CopilotChatExplain")
vim.api.nvim_del_user_command("CopilotChatFix")
vim.api.nvim_del_user_command("CopilotChatFixDiagnostic")
vim.api.nvim_del_user_command("CopilotChatOptimize")
vim.api.nvim_del_user_command("CopilotChatReview")
vim.api.nvim_del_user_command("CopilotChatTests")
----------------
--- CHEZMOI ----
----------------
-- List chezmoi files and edit them
fzf_chezmoi = function()
require("fzf-lua").fzf_exec(require("chezmoi.commands").list(), {
actions = {
["default"] = function(selected, opts)
require("chezmoi.commands").edit({
targets = { "~/" .. selected[1] },
args = { "--watch" },
})
end,
},
})
end
vim.api.nvim_command("command! ChezmoiFzf lua fzf_chezmoi()")
vim.api.nvim_del_user_command("ChezmoiEdit")
vim.api.nvim_del_user_command("ChezmoiList")
----------------
--- CUSTOM ----
----------------
-- Compare the current buffer with the original file
vim.cmd([[command DiffOrig vert new | set buftype=nofile | read ++edit # | 0d_ | diffthis | wincmd p | diffthis]])
-- Load the output of the last command into the register "o"
-- if it was executed with | tee /tmp/output.log
function load_output_to_register()
local file_path = "/tmp/output.log"
local file = io.open(file_path, "r")
if file then
local content = file:read("*all")
file:close()
vim.fn.setreg("o", content)
else
print("Failed to open file: " .. file_path)
end
end
vim.api.nvim_command("command! Output lua load_output_to_register()")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment