added nvim

This commit is contained in:
Daniel Fichtinger 2024-11-03 15:03:42 -05:00
parent 02fe17d9a1
commit 975099489a
34 changed files with 1523 additions and 0 deletions

View file

@ -0,0 +1,74 @@
-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here
vim.cmd("let &t_ut=''")
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = { "markdown" },
callback = function()
vim.opt_local.breakindent = true
vim.opt_local.wrap = true
vim.opt_local.spell = true
vim.api.nvim_buf_set_keymap(
0,
"i",
"<M-i>",
"__<Left>",
{ desc = "Markdown: Italics", noremap = true, silent = true }
)
vim.api.nvim_buf_set_keymap(0, "i", "<M-d>", "- [ ] ", { desc = "Markdown: Task", noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(
0,
"i",
"<M-a>",
"<Esc>I# ",
{ desc = "Markdown: Heading", noremap = true, silent = true }
)
vim.api.nvim_buf_set_keymap(
0,
"i",
"<M-r>",
"<Esc>I## ",
{ desc = "Markdown: Heading", noremap = true, silent = true }
)
vim.api.nvim_buf_set_keymap(
0,
"i",
"<M-s>",
"<Esc>I### ",
{ desc = "Markdown: Heading", noremap = true, silent = true }
)
vim.api.nvim_buf_set_keymap(
0,
"i",
"<M-t>",
"<Esc>I#### ",
{ desc = "Markdown: Heading", noremap = true, silent = true }
)
vim.api.nvim_buf_set_keymap(
0,
"i",
"<M-g>",
"<Esc>I##### ",
{ desc = "Markdown: Heading", noremap = true, silent = true }
)
vim.api.nvim_buf_set_keymap(
0,
"i",
"<M-b>",
"****<Left><Left>",
{ desc = "Markdown: Bold", noremap = true, silent = true }
)
vim.api.nvim_buf_set_keymap(
0,
"i",
"<M-e>",
"<Esc>I- ",
{ desc = "Markdown: Bullet Point", noremap = true, silent = true }
)
local wk = require("which-key")
wk.add({
{ "<M-i>", mode = "i", desc = "Markdown Italics" },
{ "<M-b>", mode = "i", desc = "Markdown Bold" },
})
end,
})

View file

@ -0,0 +1,120 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
local map = vim.keymap.set
local wk = require("which-key")
-- unbind ctrl S since it's tmux prefix
-- vim.keymap.del({ "i", "n" }, "<C-t>")
vim.keymap.set({ "i", "n" }, "<C-t>", "<Nop>")
local dirmap = {
up = "w0",
down = "w$",
}
local function move_cursor_to(direction) end
-- TODO: finish this
-- local function scroll(direction)
-- -- current window for now; could extend later
-- local win_id = 0
-- -- in form {line, column}
-- local current_cursor = vim.api.nvim_win_get_cursor(win_id)
--
-- -- this is the height of the window in lines
-- local win_height = vim.api.nvim_win_get_height(win_id)
--
-- local new_top = vim.fn.line(dirmap[direction])
--
-- end
-- Bind arrows to hjkl to my colemak-dh motions work as expected
map({ "n", "x" }, "<Up>", "k", { desc = "Up", remap = true })
map({ "n", "x" }, "<Down>", "j", { desc = "Down", remap = true })
map({ "n", "x" }, "<Left>", "h", { desc = "Left", remap = true })
map({ "n", "x" }, "<Right>", "l", { desc = "Right", remap = true })
-- map({ "n", "x" }, "<PageDown>", function()
-- move_cursor_to("down")
-- end, { desc = "Move cursor to bottom", remap = true })
-- map({ "n", "x" }, "<PageUp>", function()
-- move_cursor_to("up")
-- end, { desc = "Move cursor to top", remap = true })
-- map({ "n", "t" }, "<C-Left>", "<C-H>", { desc = "Switch Window Left", remap = true })
-- map({ "n", "t" }, "<C-Right>", "<C-L>", { desc = "Switch Window Right", remap = true })
-- map({ "n", "t" }, "<C-Up>", "<C-K>", { remap = true })
-- map({ "n", "t" }, "<C-Down>", "<C-J>", { desc = "Switch Window Down", remap = true })
map({ "n", "t", "i" }, "<C-Left>", "<cmd> TmuxNavigateLeft<CR>", { desc = "Switch Window Left", remap = true })
map({ "n", "t", "i" }, "<C-Right>", "<cmd> TmuxNavigateRight<CR>", { desc = "Switch Window Right", remap = true })
map({ "n", "t", "i" }, "<C-Up>", "<cmd> TmuxNavigateUp<CR>", { remap = true })
map({ "n", "t", "i" }, "<C-Down>", "<cmd> TmuxNavigateDown<CR>", { desc = "Switch Window Down", remap = true })
map({ "x" }, "<M-Left>", "<M-h>", { remap = true })
map({ "x" }, "<M-Right>", "<M-l>", { remap = true })
map({ "n", "x", "v" }, "<M-Up>", "<M-k>", { remap = true })
map({ "n", "x", "v" }, "<M-Down>", "<M-j>", { remap = true })
map({ "n" }, "<S-Left>", "H", { desc = "Left Buffer", remap = true })
map({ "n" }, "<S-Right>", "L", { desc = "Right Buffer", remap = true })
map({ "n" }, "<S-Down>", "5j", { remap = true })
map({ "n" }, "<S-Up>", "5k", { remap = true })
map({ "i" }, "<M-e>", "<Esc>", { desc = "Escape insert mode", remap = true })
-- <PageDown><PageUp>
-- Remap spelling suggestions
-- map({ "n" }, "z-", "z=", { desc = "Spelling Suggestions", remap = true })
-- Oil.nvim open parent directory
map("n", "-", "<CMD>Oil<CR>", { desc = "Open Oil" })
-- TODO: add leader + y for save current buf, leader + Y to write all
map({ "n", "x" }, "<leader>y", "<CMD>w<CR>", { desc = "Save" })
map({ "n", "x" }, "<leader>Y", "<CMD>wa<CR>", { desc = "Save All" })
-- Zen Mode
map("n", "<leader>uz", "<CMD>ZenMode<CR>", { desc = "Toggle Zen Mode" })
-- Source Current File
map("n", "<leader><leader>x", "<CMD>source %<CR>", { desc = "Source current file" })
-- Obsidian
-- <leader>o is the prefix for all Obsidian bindings
wk.add({
{ "<leader>o", group = "Obsidian" },
{ "<leader>od", group = "Daily Note" },
{ "<leader>ol", group = "Follow Link" },
})
map("n", "<leader>oo", "<CMD>ObsidianQuickSwitch<CR>", { desc = "Obsidian Quick Switch" })
map("n", "<leader>o/", "<CMD>ObsidianSearch<CR>", { desc = "Obsidian Grep" })
-- This one will open the command line and let the user type the arg
map("n", "<leader>on", function()
require("command-key").command("ObsidianNew")
end, { desc = "Obsidian New Note" })
map("n", "<leader>ob", "<CMD>ObsidianBacklinks<CR>", { desc = "Obsidian Backlinks" })
-- map("n", "<leader>ot", function()
-- require("command-key").command("ObsidianTags")
-- end, { desc = "Obsidian Tags" })
map("n", "<leader>ot", "<CMD>ObsidianTags<CR>", { desc = "Obsidian Tags" })
map("n", "<leader>olv", "<CMD>ObsidianFollowLink vsplit<CR>", { desc = "Obsidian Follow Link Vsplit" })
map("n", "<leader>olh", "<CMD>ObsidianFollowLink hsplit<CR>", { desc = "Obsidian Follow Link Hsplit" })
map("n", "<leader>odt", "<CMD>ObsidianToday<CR>", { desc = "Obsidian Open Today's Daily" })
map("n", "<leader>ods", "<CMD>ObsidianDailies<CR>", { desc = "Obsidian Search Dailies" })
map("n", "<leader>ols", "<CMD>ObsidianLinks<CR>", { desc = "Obsidian Search Links" })
map("x", "<leader>oll", function()
require("command-key").command("ObsidianLink")
end, { desc = "Obsidian Link Visual To Existing Note" })
map("x", "<leader>oln", function()
require("command-key").command("ObsidianLinkNew")
end, { desc = "Obsidian Link Visual To New Note" })
map("x", "<leader>ole", function()
require("command-key").command("ObsidianExtractNote")
end, { desc = "Obsidian Copy Selection To New Note & Link" })
map("n", "<leader>or", function()
require("command-key").command("ObsidianRename")
end, { desc = "Obsidian Rename" })
map("n", "<leader>oc", "<CMD>ObsidianTOC<CR>", { desc = "Obsidian Table Of Contents" })
-- TODO: Add binds for templates

View file

@ -0,0 +1,53 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = {
enabled = true, -- check for plugin updates periodically
notify = false, -- notify on update
}, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})

View file

@ -0,0 +1,4 @@
-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here
vim.o.scrolloff = 2