recovering custom nvim configs

This commit is contained in:
Rahsheen Porter 2024-03-03 11:26:12 -05:00
parent 0622ef41cd
commit ebb0a5aeed
11 changed files with 340 additions and 5 deletions

View File

@ -0,0 +1,2 @@
require("rahcodes.remap")
require("rahcodes.sets")

21
after/plugin/fugitive.lua Normal file
View File

@ -0,0 +1,21 @@
vim.keymap.set("n", "<leader>gs", ":G<CR>")
vim.keymap.set("n", "<leader>gh", ":diffget //3<CR>")
vim.keymap.set("n", "<leader>gu", ":diffget //2<CR>")
vim.keymap.set("n", "<leader>gc", ":GCheckout<CR>")
vim.keymap.set("n", "<leader>ga", ":G add %:p<CR><CR>")
vim.keymap.set("n", "<leader>gc", ":G commit -v -q<CR>")
vim.keymap.set("n", "<leader>gt", ":G commit -v -q %:p<CR>")
vim.keymap.set("n", "<leader>gff", ":G ff<CR>")
vim.keymap.set("n", "<leader>gfo", ":G fetch origin<CR>")
vim.keymap.set("n", "<leader>gd", ":Gdiff<CR>")
vim.keymap.set("n", "<leader>ge", ":Gedit<CR>")
vim.keymap.set("n", "<leader>gr", ":Gread<CR>")
vim.keymap.set("n", "<leader>grb", ":G rebase -i<CR>")
vim.keymap.set("n", "<leader>gw", ":Gwrite<CR><CR>")
vim.keymap.set("n", "<leader>gl", ":silent! Glog<CR>:bot copen<CR>")
vim.keymap.set("n", "<leader>gp", ":Ggrep<Space>")
vim.keymap.set("n", "<leader>gm", ":Gmove<Space>")
vim.keymap.set("n", "<leader>gbl", ":G blame<CR>")
vim.keymap.set("n", "<leader>go", ":G checkout<Space>")
vim.keymap.set("n", "<leader>gps", ":Dispatch! git push<CR>")
vim.keymap.set("n", "<leader>gpl", ":Dispatch! git pull<CR>")

View File

@ -0,0 +1,22 @@
local Worktree = require("git-worktree")
-- op = Operations.Switch, Operations.Create, Operations.Delete
-- metadata = table of useful values (structure dependent on op)
-- Switch
-- path = path you switched to
-- prev_path = previous worktree path
-- Create
-- path = path where worktree created
-- branch = branch name
-- upstream = upstream remote name
-- Delete
-- path = path where worktree deleted
Worktree.on_tree_change(function(op, metadata)
if op == Worktree.Operations.Switch then
print("Switched from " .. metadata.prev_path .. " to " .. metadata.path)
end
end)
vim.keymap.set("n", "<leader>bw", require("telescope").extensions.git_worktree.git_worktrees, { desc = "[B]rowse Git Worktrees" })
vim.keymap.set("n", "<leader>cw", require("telescope").extensions.git_worktree.create_git_worktree, { desc = "[C]reate Git [W]orktree" })

13
after/plugin/lualine.lua Normal file
View File

@ -0,0 +1,13 @@
require("lualine").setup({
options = {
theme = "tokyonight",
tabline = {
lualine_a = { "buffers" },
lualine_b = { "branch" },
lualine_c = { "filename" },
lualine_x = {},
lualine_y = {},
lualine_z = { "tabs" },
},
},
})

75
after/plugin/null-ls.lua Normal file
View File

@ -0,0 +1,75 @@
local setup, null_ls = pcall(require, "null-ls")
if not setup then
return
end
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
local conditional = function(fn)
local utils = require("null-ls.utils").make_conditional_utils()
return fn(utils)
end
local lsp_formatting = function(bufnr)
vim.lsp.buf.format({
timeout_ms = 2000,
filter = function(client)
-- apply whatever logic you want (in this example, we'll only use null-ls)
return client.name ~= "tsserver"
end,
bufnr = bufnr,
})
end
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
-- local my_rubocop_formatter = require("rahcodes.null-ls.rubocop")
local rubocop = null_ls.builtins.formatting.rubocop
null_ls.setup({
debug = false,
sources = {
formatting.prettier,
-- formatting.stylua,
null_ls.builtins.code_actions.gitsigns,
-- setting eslint_d only if we have a ".eslintrc.js" file in the project
diagnostics.eslint_d.with({
condition = function(utils)
return utils.root_has_file({ '.eslintrc.js' })
end
}),
-- Here we set a conditional to call the rubocop formatter. If we have a Gemfile in the project, we call "bundle exec rubocop", if not we only call "rubocop".
conditional(function(utils)
return utils.root_has_file("Gemfile")
and rubocop.with({
command = "bundle",
args = vim.list_extend({ "exec", "rubocop" }, rubocop._opts.args),
})
or rubocop
end),
-- Same as above, but with diagnostics.rubocop to make sure we use the proper rubocop version for the project
conditional(function(utils)
return utils.root_has_file("Gemfile")
and null_ls.builtins.diagnostics.rubocop.with({
command = "bundle",
args = vim.list_extend({ "exec", "rubocop" }, null_ls.builtins.diagnostics.rubocop._opts.args),
})
or null_ls.builtins.diagnostics.rubocop
end),
},
-- format on save
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
lsp_formatting(bufnr)
end,
})
end
end,
})

View File

@ -0,0 +1,2 @@
pcall(require("telescope").load_extension, "ui-select")
pcall(require("telescope").load_extension, "live_grep_args")

View File

@ -1,5 +1,68 @@
-- You can add your own plugins here or in other files in this directory! return {
-- I promise not to create any merge conflicts in this directory :) {
-- "ThePrimeagen/refactoring.nvim",
-- See the kickstart.nvim README for more information requires = {
return {} { "nvim-lua/plenary.nvim" },
{ "nvim-treesitter/nvim-treesitter" },
},
config = function()
require("refactoring").setup({})
end,
},
{
"ThePrimeagen/git-worktree.nvim",
},
{
"folke/tokyonight.nvim",
lazy = false, -- make sure we load this during startup if it is your main colorscheme
priority = 1000, -- make sure to load this before all the other start plugins
config = function()
-- load the colorscheme here
vim.cmd([[colorscheme tokyonight]])
end,
},
-- formatting & linting
"jose-elias-alvarez/null-ls.nvim",
-- use("jayp0521/mason-null-ls.nvim")
{
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
event = "VeryLazy",
config = function()
require("nvim-surround").setup({
-- Configuration here, or leave empty to use defaults
})
end,
},
{
"folke/trouble.nvim",
requires = "nvim-tree/nvim-web-devicons",
config = function()
require("trouble").setup({
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
})
end,
},
{
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end,
},
{
"nvim-telescope/telescope.nvim",
dependencies = {
{
"nvim-telescope/telescope-live-grep-args.nvim",
-- This will not install any breaking changes.
-- For major updates, this must be adjusted manually.
version = "^1.0.0",
},
},
config = function()
require("telescope").load_extension("live_grep_args")
end
}
}

20
lua/rahcodes/keymap.lua Normal file
View File

@ -0,0 +1,20 @@
local M = {}
local function bind(op, outer_opts)
outer_opts = outer_opts or {noremap = true}
return function(lhs, rhs, opts)
opts = vim.tbl_extend("force",
outer_opts,
opts or {}
)
vim.keymap.set(op, lhs,rhs, opts)
end
end
M.nmap = bind("n", {noremap = false})
M.nnoremap = bind("n")
M.vnoremap = bind("v")
M.xnoremap = bind("x")
M.inoremap = bind("i")
return M

69
lua/rahcodes/remap.lua Normal file
View File

@ -0,0 +1,69 @@
local Remap = require("rahcodes.keymap")
local nmap = Remap.nmap
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- don't bork paste buffer when pasting
vim.keymap.set("x", "<leader>p", '"_dP')
vim.keymap.set("i", "<C-c>", "<Esc>")
-- vim.keymap.set("n", "/", "/\v")
-- vim.keymap.set("v", "/", "/\v")
vim.keymap.set("n", "<leader>`", ":noh<cr>")
-- No Cheating
vim.keymap.set("n", "<up>", "<nop>")
vim.keymap.set("n", "<down>", "<nop>")
vim.keymap.set("n", "<left>", "<nop>")
vim.keymap.set("n", "<right>", "<nop>")
vim.keymap.set("i", "<up>", "<nop>")
vim.keymap.set("i", "<down>", "<nop>")
vim.keymap.set("i", "<left>", "<nop>")
vim.keymap.set("i", "<right>", "<nop>")
-- No weird line jumps
vim.keymap.set("n", "j", "gj")
vim.keymap.set("n", "k", "gk")
-- Copy to system clipboard
vim.keymap.set("n", "<leader>y", '"*y')
vim.keymap.set("v", "<leader>y", '"*y')
vim.keymap.set("n", "<leader>yy", '"+y')
vim.keymap.set("v", "<leader>yy", '"+y')
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>")
-- Move buffers
nmap("sp", ":bprev<Return>")
nmap("sn", ":bnext<Return>")
-- Quickfix list navigation
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
-- Save
nmap("<C-s>", ":wa<CR>")
-- See `:help telescope.builtin`
vim.keymap.set("n", "<leader>m", require("telescope.builtin").oldfiles, { desc = "[?] Find recently opened files" })
vim.keymap.set("n", "<leader>/", require("telescope.builtin").find_files, { desc = "[S]earch [F]iles" })
-- Trouble bindings
vim.keymap.set("n", "<leader>xx", function() require("trouble").open() end)
vim.keymap.set("n", "<leader>xw", function() require("trouble").open("workspace_diagnostics") end)
vim.keymap.set("n", "<leader>xd", function() require("trouble").open("document_diagnostics") end)
vim.keymap.set("n", "<leader>xq", function() require("trouble").open("quickfix") end)
vim.keymap.set("n", "<leader>xl", function() require("trouble").open("loclist") end)
vim.keymap.set("n", "gR", function() require("trouble").open("lsp_references") end)

26
lua/rahcodes/sets.lua Normal file
View File

@ -0,0 +1,26 @@
vim.opt.guicursor = ""
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.wrap = false
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.incsearch = true
vim.opt.scrolloff = 8
vim.opt.isfname:append("@-@")
vim.opt.colorcolumn = "80"
vim.opt.mouse = "v"

View File

@ -0,0 +1,22 @@
local lsp = require 'lspconfig'
lsp.solargraph.setup {
cmd = { os.getenv("HOME") .. "/.asdf/shims/solargraph", '--stdio' },
filetypes = { "ruby", "rakefile" },
settings = {
solargraph = {
-- root_dir = nvim_lsp.util.root_pattern("Gemfile", ".git", "."),
-- root_dir = root_pattern("Gemfile", ".git"),
settings = {
solargraph = {
autoformat = true,
completion = true,
diagnostic = true,
folding = true,
references = true,
rename = true,
symbols = true
}
}
},
}
}