~kota/dots

e034653af6b7523d67c591d245d0dd648d6d604b — Dakota Walsh 1 year, 8 months ago af731da
neovim tweaks
M git/.gitignore_global => git/.gitignore_global +1 -1
@@ 1,3 1,3 @@
# Direnv stuff
.autoenv.zsh
.vim-bookmarks
.viminfo

A neovim/.config/nvim/after/ftplugin/help.vim => neovim/.config/nvim/after/ftplugin/help.vim +4 -0
@@ 0,0 1,4 @@
if !exists('w:help_is_moved') || w:help_is_moved != "right"
  wincmd L
  let w:help_is_moved = "right"
endif

M neovim/.config/nvim/lua/maps.lua => neovim/.config/nvim/lua/maps.lua +41 -24
@@ 18,7 18,7 @@ map('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
map('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })

-- Disable search highlighting
map('n', '<space>n', ':nohl<CR>', snoremap)
map('n', '<space>c', ':nohl<CR>', snoremap)

-- Toggle hidden characters
map('n', '<space>sh', ':set list!<cr>', snoremap)


@@ 59,19 59,19 @@', noremap)
map('n', '<space>o', ':BufOnly<CR>', snoremap)
map('n', '<space>O', ':only<CR>', snoremap)

-- Hop around
map('n', '<space><space>', "", {
-- Telescope binds
map("n", "<space><space>", "", {
	noremap = true,
	callback = function()
		require 'hop'.hint_char2()
	end
		require("telescope.builtin").find_files()
	end,
})

-- Telescope binds
map("n", "<space>f", "", {
map("n", "<space>n", "", {
	noremap = true,
	callback = function()
		require("telescope.builtin").find_files()
		require("telescope.builtin").resume()
	end,
})



@@ 82,7 82,7 @@ map("n", "<space>/", "", {
	end,
})

map("n", "<space>G", "", {
map("n", "<space>gg", "", {
	noremap = true,
	callback = function()
		require("telescope.builtin").git_status()


@@ 99,63 99,67 @@ map("n", "<space>m", "", {
map("n", "<space>b", "", {
	noremap = true,
	callback = function()
		require("telescope.builtin").buffers()
		require("telescope.builtin").buffers({
			show_all_buffers = false,
			ignore_current_buffer = true,
			sort_mru = true,
		})
	end,
})

map("n", "<space>B", "", {
	noremap = true,
	callback = function()
		require("telescope.builtin").oldfiles()
		require("telescope.builtin").oldfiles({cwd_only=true})
	end,
})

map("n", "z=", "", {
map("n", "<space>H", "", {
	noremap = true,
	callback = function()
		require("telescope.builtin").spell_suggest()
		require("telescope.builtin").command_history()
	end,
})

map("n", "<space>h", "", {
map("n", "z=", "", {
	noremap = true,
	callback = function()
		require("telescope.builtin").help_tags()
		require("telescope.builtin").spell_suggest()
	end,
})

map("n", "<space>k", "", {
map("n", "z-", "", {
	noremap = true,
	callback = function()
		require("telescope.builtin").keymaps()
		require("telescope").extensions.thesaurus.synonyms()
	end,
})

map("n", "gr", "", {
map("n", "<space>h", "", {
	noremap = true,
	callback = function()
		require("telescope.builtin").lsp_references()
		require("telescope.builtin").help_tags()
	end,
})

map("n", "<space>ca", "", {
map("n", "<space>k", "", {
	noremap = true,
	callback = function()
		require("telescope.builtin").lsp_code_actions()
		require("telescope.builtin").keymaps()
	end,
})

map("n", "ma", "", {
map("n", "gr", "", {
	noremap = true,
	callback = function()
		require('telescope').extensions.vim_bookmarks.all()
		require("telescope.builtin").lsp_references()
	end,
})

map("n", "mA", "", {
map("n", "<space>a", "", {
	noremap = true,
	callback = function()
		require('telescope').extensions.vim_bookmarks.current_file()
		require("telescope.builtin").lsp_code_actions()
	end,
})



@@ 198,3 202,16 @@ map('n', '<C-j>', '<C-W><C-j>', snoremap)
map('n', '<C-k>', '<C-W><C-k>', snoremap)
map('n', '<C-l>', '<C-W><C-l>', snoremap)
map('n', '<C-h>', '<C-W><C-h>', snoremap)

-- New Project (for project-scoped marks and oldfiles)
vim.api.nvim_create_user_command(
    'Pnew',
    function()
		local file = io.open(".viminfo", "w")
		if file == nil then
			return
		end
		file:close()
    end,
    { nargs = 0 }
)

A neovim/.config/nvim/lua/plugins/dashboard.lua => neovim/.config/nvim/lua/plugins/dashboard.lua +218 -0
@@ 0,0 1,218 @@
local if_nil = vim.F.if_nil
local fnamemodify = vim.fn.fnamemodify
local filereadable = vim.fn.filereadable

local default_header = {
	type = "text",
	val = {
		[[             .-   .-.             ]],
		[[         .-.(  )-(   )            ]],
		[[        ( .   (   .   )           ]],
		[[       (  (    (___(_.))          ]],
		[[      ..________..\    ..         ]],
		[[  .-.                        .-.  ]],
		[[ (__.)               =      (__.) ]],
		[[                     |\           ]],
		[[                    /|o\          ]],
		[[           ~~~  ~~~/_|__\~~~~ ~   ]],
		[[                 ~~ˋ~~~~ˊ~~       ]],
		[[             ~~ ~     ~~~~~~~ ~   ]],
	},
	opts = {
		hl = "Type",
		shrink_margin = false,
		-- wrap = "overflow";
	},
}

local leader = "SPC"

--- @param sc string
--- @param txt string
--- @param keybind string? optional
--- @param keybind_opts table? optional
local function button(sc, txt, keybind, keybind_opts)
	local sc_ = sc:gsub("%s", ""):gsub(leader, "<leader>")

	local opts = {
		shortcut = "[" .. sc .. "] ",
		cursor = 1,
		align_shortcut = "left",
		hl_shortcut = { { "Operator", 0, 1 }, { "Number", 1, #sc + 1 }, { "Operator", #sc + 1, #sc + 2 } },
		shrink_margin = false,
	}
	if keybind then
		keybind_opts = if_nil(keybind_opts, { noremap = true, silent = true, nowait = true })
		opts.keymap = { "n", sc_, keybind, { noremap = false, silent = true, nowait = true } }
	end

	local function on_press()
		-- local key = vim.api.nvim_replace_termcodes(keybind .. "<Ignore>", true, false, true)
		local key = vim.api.nvim_replace_termcodes(sc_ .. "<Ignore>", true, false, true)
		vim.api.nvim_feedkeys(key, "t", false)
	end

	return {
		type = "button",
		val = txt,
		on_press = on_press,
		opts = opts,
	}
end

local nvim_web_devicons = {
	enabled = true,
	highlight = true,
}

local function get_extension(fn)
	local match = fn:match("^.+(%..+)$")
	local ext = ""
	if match ~= nil then
		ext = match:sub(2)
	end
	return ext
end

local function icon(fn)
	local nwd = require("nvim-web-devicons")
	local ext = get_extension(fn)
	return nwd.get_icon(fn, ext, { default = true })
end

local function file_button(fn, sc, short_fn)
	short_fn = if_nil(short_fn, fn)
	local ico_txt
	local fb_hl = {}
	if nvim_web_devicons.enabled then
		local ico, hl = icon(fn)
		local hl_option_type = type(nvim_web_devicons.highlight)
		if hl_option_type == "boolean" then
			if hl and nvim_web_devicons.highlight then
				table.insert(fb_hl, { hl, 0, 1 })
			end
		end
		if hl_option_type == "string" then
			table.insert(fb_hl, { nvim_web_devicons.highlight, 0, 1 })
		end
		ico_txt = ico .. "  "
	else
		ico_txt = ""
	end
	local file_button_el = button(sc, ico_txt .. short_fn, "<cmd>e " .. fn .. " <CR>")
	local fn_start = short_fn:match(".*[/\\]")
	if fn_start ~= nil then
		table.insert(fb_hl, { "Comment", #ico_txt - 2, #fn_start + #ico_txt - 2 })
	end
	file_button_el.opts.hl = fb_hl
	return file_button_el
end

local default_mru_ignore = { "gitcommit" }

local mru_opts = {
	ignore = function(path, ext)
		return (string.find(path, "COMMIT_EDITMSG")) or (vim.tbl_contains(default_mru_ignore, ext))
	end,
}

--- @param start number
--- @param cwd string? optional
--- @param items_number number? optional number of items to generate, default = 10
local function mru(start, cwd, items_number, opts)
	opts = opts or mru_opts
	items_number = if_nil(items_number, 10)
	local oldfiles = {}
	for _, v in pairs(vim.v.oldfiles) do
		if #oldfiles == items_number then
			break
		end
		local cwd_cond
		if not cwd then
			cwd_cond = true
		else
			cwd_cond = vim.startswith(v, cwd)
		end
		local ignore = (opts.ignore and opts.ignore(v, get_extension(v))) or false
		if (filereadable(v) == 1) and cwd_cond and not ignore then
			oldfiles[#oldfiles + 1] = v
		end
	end

	local tbl = {}
	for i, fn in ipairs(oldfiles) do
		local short_fn
		if cwd then
			short_fn = fnamemodify(fn, ":.")
		else
			short_fn = fnamemodify(fn, ":~")
		end
		local file_button_el = file_button(fn, tostring(i + start - 1), short_fn)
		tbl[i] = file_button_el
	end
	return {
		type = "group",
		val = tbl,
		opts = {},
	}
end

local function mru_title()
	return vim.fn.getcwd()
end

local section = {
	header = default_header,
    top_buttons = {
        type = "group",
        val = {
            button("e", "New file", "<cmd>ene <CR>"),
        },
    },
	mru_cwd = {
		type = "group",
		val = {
			{ type = "text", val = mru_title, opts = { hl = "SpecialComment", shrink_margin = false } },
			{ type = "padding", val = 1 },
			{
				type = "group",
				val = function()
					return { mru(0, vim.fn.getcwd()) }
				end,
				opts = { shrink_margin = false },
			},
		},
	},
	bottom_buttons = {
		type = "group",
		val = {
			button("q", "Quit", "<cmd>q <CR>"),
		},
	},
}

local config = {
	layout = {
		{ type = "padding", val = 1 },
		section.header,
		{ type = "padding", val = 1 },
        section.top_buttons,
		{ type = "padding", val = 1 },
		section.mru_cwd,
		{ type = "padding", val = 1 },
		section.bottom_buttons,
	},
	opts = {
		margin = 3,
		redraw_on_resize = false,
		setup = function()
			vim.cmd([[
            autocmd alpha_temp DirChanged * lua require('alpha').redraw()
            ]])
		end,
	},
}

return {
	config = config,
}

M neovim/.config/nvim/lua/settings.lua => neovim/.config/nvim/lua/settings.lua +5 -1
@@ 15,7 15,11 @@ o.cmdheight = 2
o.scrolloff = 4
o.sidescrolloff = 5
o.termguicolors = true
o.background = "dark"

-- Project-local marks and oldfiles!
o.viminfofile=vim.api.nvim_eval([[findfile('.viminfo','.;')]])
-- use :Pnew to "create" a new project
-- or touch .viminfo :D

-- Use dirbuf instead of netrw
g.loaded_netrwPlugin = 1

M neovim/.config/nvim/spell/en.utf-8.add => neovim/.config/nvim/spell/en.utf-8.add +1 -0
@@ 42,3 42,4 @@ linux
fsf
fsf's
minikube
pepperoncini

M neovim/.config/nvim/spell/en.utf-8.add.spl => neovim/.config/nvim/spell/en.utf-8.add.spl +0 -0