added neovim

This commit is contained in:
Michael Thomson 2024-02-27 12:00:15 -05:00
parent 6d007ba2f7
commit c6af5c0161
No known key found for this signature in database
26 changed files with 616 additions and 0 deletions

View File

@ -2,6 +2,7 @@
{ {
imports = [ imports = [
../../modules/home-manager/neovim
../../modules/home-manager/wezterm ../../modules/home-manager/wezterm
../../modules/home-manager/zsh ../../modules/home-manager/zsh
]; ];

View File

@ -0,0 +1,11 @@
{ pkgs, config, ... }:
{
home.packages = with pkgs; [
noevim
];
home.file.".config/nvim/" = {
source = ./nvim;
recursive = true;
};
}

View File

@ -0,0 +1,76 @@
# My Neovim Config
<a href="https://dotfyle.com/michaelthomson0797/nvim"><img src="https://dotfyle.com/michaelthomson0797/nvim/badges/plugins?style=flat" /></a>
<a href="https://dotfyle.com/michaelthomson0797/nvim"><img src="https://dotfyle.com/michaelthomson0797/nvim/badges/leaderkey?style=flat" /></a>
<a href="https://dotfyle.com/michaelthomson0797/nvim"><img src="https://dotfyle.com/michaelthomson0797/nvim/badges/plugin-manager?style=flat" /></a>
![Screenshot 2023-10-19 at 2 16 29 PM](https://github.com/michaelthomson0797/nvim/assets/8810940/170440a7-aadb-4e88-b45e-02e7737a3d28)
<!--toc:start-->
- [My Neovim Config](#my-neovim-config)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Plugins used](#plugins-used)
- [Basic Keybinds](#basic-keybinds)
- [Project Navigation](#project-navigation)
- [File Navigation](#file-navigation)
- [LSP Commands](#lsp-commands)
<!--toc:end-->
An okay config
## Prerequisites
- `neovim`
- `git`
- `fzf`
- `ripgrep`
## Installation
Clone this folder, or copy all the contents to `~/.config/nvim/`
## Plugins used
- `lazy.nvim`: Package manager that manages installed plugins
- `lsp-zero`: Basic configurations for providing language server support like autocompletion, intellisense, diagnostics, etc.
- `alpha-nvim`: Splash screen when starting neovim
- `fidget.nvim`: LSP status indicator
- `gitsigns.nvim`: File change indicators in the buffer gutter
- `harpoon`: Project-specific file bookmarking and rapid navigation
- `leap.nvim`: Fast file navigation by jumping to characters in the buffer
- `lspsaga.nvim`: UI replacement for many LSP function (rename, documentation hover, etc.)
- `lualine.nvim`: Status with nice styling
- `mini.nvim`: A collection of utilities
- `mini.comment`: Apply language sensitive comments
- `mini.pairs`: automatically pair parens, quotes, etc.
- `mini.surround`: Quickly add, edit, delete surroundings (parens, quotes, etc.)
- `mini.splitjoin`: quickly split or join a list
- `mini.jump`: enhanced f/F/t/T movement
- `neo-tree.nvim`: File tree explorer and editor
- `noice.nvim`: Fancy UI replacements
- `nvim-ts-autotag`: Automatic pairing of HTML tags in `.html`, `.jsx`, `.tsx`
- `telescope.nvim`: Fuzzy file and text finder
- `toggleterm.nvim`: Quickly toggle integrated terminal on and off
- `nvim-treesitter`: Syntax tree parsing
- `trouble.nvim`: Diagnostics listing
- `undotree`: Show file undo/redo history as a tree and traverse it
## Basic Keybinds
### Project Navigation
- `<leader>fe`: open file explorer
- `<leader>ff`: fuzzy find files in project
- `<leader>fg`: fuzzy find text in project
- `<leader>fg`: fuzzy find text in project
### File Navigation
- `s{c1}{c2}`: searches the active buffer for the two provided characters and provides prompts to press to instantly navigate to that pair
### LSP Commands
- `gd`: Go to definition
- `gr`: Go to references
- `<leader>rn`: Rename symbol
- `<leader>ca`: Code actions
- `<leader>ds`: Fuzzy find document symbols
- `<leader>ws`: Fuzzy find workspace symbols
- `[d`/`]d`: Jump to next/prev diagnostic
- `K`: Show symbol documentation
- `<leader>o`: show outline

View File

@ -0,0 +1,96 @@
local api = vim.api
local g = vim.g
local opt = vim.opt
-- Load Lazy
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)
-- Remap leader and local leader to <Space>
api.nvim_set_keymap("", "<Space>", "<Nop>", { noremap = true, silent = true })
g.mapleader = " "
g.maplocalleader = " "
-- Load plugins
require('lazy').setup('plugins')
vim.cmd 'colorscheme catppuccin-frappe'
-- Load core settings
opt.termguicolors = true -- Enable colors in terminal
opt.hlsearch = false -- turn off highlight on search
opt.incsearch = true -- Keep incremental highlighting on search
opt.number = true --Make line numbers default
opt.relativenumber = true --Make relative number default
opt.mouse = "a" --Enable mouse mode
opt.breakindent = true --Enable break indent
opt.undofile = true --Save undo history
opt.ignorecase = true --Case insensitive searching unless /C or capital in search
opt.smartcase = true -- Smart case
opt.updatetime = 50 --Decrease update time
opt.signcolumn = "yes" -- Always show sign column
opt.clipboard = "unnamedplus" -- Access system clipboard
opt.laststatus = 3 -- Global status line
opt.swapfile = false
opt.wrap = false
-- Time in milliseconds to wait for a mapped sequence to complete.
opt.timeoutlen = 300
opt.showmode = false -- Do not need to show the mode. We use the statusline instead.
-- opt.scrolloff = 8 -- Lines of context
opt.smartindent = true --Smart indent
opt.expandtab = true
opt.smarttab = true
opt.textwidth = 0
opt.autoindent = true
opt.shiftwidth = 2
opt.tabstop = 2
opt.softtabstop = 2
opt.splitbelow = true
opt.splitright = true
opt.cursorline = true
opt.guifont = "PragmataPro Mono Liga"
-- Remappings
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")
vim.keymap.set("x", "<leader>p", [["_dP]])
vim.keymap.set({"n", "v"}, "<leader>y", [["+y]])
vim.keymap.set("n", "<leader>Y", [["+Y]])
vim.keymap.set({"n", "v"}, "<leader>d", [["_d]])
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "<c-f>", "<nop>")
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>")
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<leader>fe", "<cmd>Explore<CR>")
vim.keymap.set("i", "jk", "<Esc>")
vim.cmd[[
augroup highlight_yank
autocmd!
au TextYankPost * silent! lua vim.highlight.on_yank({higroup="Visual", timeout=200})
augroup END
]]

View File

@ -0,0 +1,5 @@
{
"diagnostics.globals": [
"vim"
]
}

View File

@ -0,0 +1,5 @@
return {
'windwp/nvim-autopairs',
event = "InsertEnter",
opts = {} -- this is equalent to setup({}) function
}

View File

@ -0,0 +1,19 @@
return {
"catppuccin/nvim",
name = "catppuccin",
priority = 1000,
opts = {
integrations = {
cmp = true,
gitsigns = true,
treesitter = true,
fidget = true,
harpoon = true,
leap = true,
mason = true,
telescope = {
enabled = true,
},
},
},
}

View File

@ -0,0 +1,7 @@
return {
'numToStr/Comment.nvim',
opts = {
-- add any options here
},
lazy = false,
}

View File

@ -0,0 +1,10 @@
return {
'j-hui/fidget.nvim',
opts = {
notification = {
window = {
winblend = 0,
},
}
}
}

View File

@ -0,0 +1,7 @@
return {
"m4xshen/hardtime.nvim",
dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" },
opts = {
disabled_filetypes = {"qf", "netrw", "NvimTree", "lazy", "mason", "oil", "telescope"}
}
}

View File

@ -0,0 +1,9 @@
return {
'theprimeagen/harpoon',
keys = {
{ "<leader>a", function() require('harpoon.mark').add_file() end },
{ "<leader>e", function() require('harpoon.ui').toggle_quick_menu() end },
{ "<leader>k", function() require('harpoon.ui').nav_next() end },
{ "<leader>j", function() require('harpoon.ui').nav_prev() end },
}
}

View File

@ -0,0 +1,41 @@
return {
"tris203/hawtkeys.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = {
leader = " ", -- the key you want to use as the leader, default is space
homerow = 2, -- the row you want to use as the homerow, default is 2
powerFingers = { 2, 3, 6, 7 }, -- the fingers you want to use as the powerfingers, default is {2,3,6,7}
keyboardLayout = "qwerty", -- the keyboard layout you use, default is qwerty
customMaps = {
--- EG local map = vim.api
--- map.nvim_set_keymap('n', '<leader>1', '<cmd>echo 1')
{
["map.nvim_set_keymap"] = { --name of the expression
modeIndex = "1", -- the position of the mode setting
lhsIndex = "2", -- the position of the lhs setting
rhsIndex = "3", -- the position of the rhs setting
optsIndex = "4", -- the position of the index table
method = "dot_index_expression", -- if the function name contains a dot
},
},
--- EG local map2 = vim.api.nvim_set_keymap
["map2"] = { --name of the function
modeIndex = 1, --if you use a custom function with a fixed value, eg normRemap, then this can be a fixed mode eg 'n'
lhsIndex = 2,
rhsIndex = 3,
optsIndex = 4,
method = "function_call",
},
-- If you use lazy.nvim's keys property to configure keymaps in your plugins
["lazy"] = {
method = "lazy",
},
},
highlights = { -- these are the highlight used in search mode
HawtkeysMatchGreat = { fg = "green", bold = true },
HawtkeysMatchGood = { fg = "green"},
HawtkeysMatchOk = { fg = "yellow" },
HawtkeysMatchBad = { fg = "red" },
},
},
}

View File

@ -0,0 +1,6 @@
return {
'ggandor/leap.nvim',
config = function()
require("leap").set_default_keymaps()
end
}

View File

@ -0,0 +1,81 @@
return {
'VonHeikemen/lsp-zero.nvim',
branch = 'v3.x',
dependencies = {
-- LSP Support
{'neovim/nvim-lspconfig'}, -- Required
{'williamboman/mason.nvim'}, -- Optional
{'williamboman/mason-lspconfig.nvim'}, -- Optional
-- Autocompletion
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'L3MON4D3/LuaSnip'}, -- Required
{'saadparwaiz1/cmp_luasnip'},
{'onsails/lspkind.nvim'} -- Optional
},
config = function()
local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr)
local opts = {buffer = bufnr, remap = false}
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
vim.keymap.set("n", "gr", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
vim.keymap.set("n", "<leader>ws", function() vim.lsp.buf.workspace_symbol() end, opts)
vim.keymap.set("n", "<leader>d", function() vim.diagnostic.open_float() end, opts)
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
vim.keymap.set("n", "<leader>ca", function() vim.lsp.buf.code_action() end, opts)
vim.keymap.set("n", "<leader>rn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
end)
-- Mason Config
require('mason').setup({})
require('mason-lspconfig').setup({
ensure_installed = {},
handlers = {
lsp_zero.default_setup,
}
})
-- cmp Config
local cmp = require('cmp')
local cmp_action = require('lsp-zero').cmp_action()
cmp.setup({
sources = {
{name = 'path'},
{name = 'nvim_lsp'},
{name = 'nvim_lua'},
{name = 'luasnip'},
{name = 'cmp_luasnip'},
{name = 'buffer'},
{name = 'neorg'}
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = {'abbr', 'kind', 'menu'},
format = require('lspkind').cmp_format({
mode = 'symbol', -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead
})
},
mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm({select = false}),
-- scroll up and down the documentation window
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
-- ['<Tab>'] = cmp_action.luasnip_supertab(),
-- ['<S-Tab>'] = cmp_action.luasnip_shift_supertab(),
}),
})
end,
}

View File

@ -0,0 +1,12 @@
return {
"L3MON4D3/LuaSnip",
dependencies = { "rafamadriz/friendly-snippets" },
-- follow latest release.
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp",
config = function ()
require('luasnip.loaders.from_vscode').lazy_load()
end
}

View File

@ -0,0 +1,19 @@
return {
"christoomey/vim-tmux-navigator",
cmd = {
"TmuxNavigateLeft",
"TmuxNavigateDown",
"TmuxNavigateUp",
"TmuxNavigateRight",
"TmuxNavigatePrevious",
},
keys = {
{ "<c-h>", "<cmd><C-U>TmuxNavigateLeft<cr>" },
{ "<c-j>", "<cmd><C-U>TmuxNavigateDown<cr>" },
{ "<c-k>", "<cmd><C-U>TmuxNavigateUp<cr>" },
{ "<c-l>", "<cmd><C-U>TmuxNavigateRight<cr>" },
{ "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
},
}

View File

@ -0,0 +1,3 @@
return {
'windwp/nvim-ts-autotag',
}

View File

@ -0,0 +1,22 @@
return {
"giusgad/pets.nvim",
dependencies = { "MunifTanjim/nui.nvim", "giusgad/hologram.nvim" },
config = function ()
require("pets").setup({
row = 1, -- the row (height) to display the pet at (higher row means the pet is lower on the screen), must be 1<=row<=10
col = 0, -- the column to display the pet at (set to high number to have it stay still on the right side)
speed_multiplier = 1, -- you can make your pet move faster/slower. If slower the animation will have lower fps.
default_pet = "dog", -- the pet to use for the PetNew command
default_style = "brown", -- the style of the pet to use for the PetNew command
random = true, -- whether to use a random pet for the PetNew command, overrides default_pet and default_style
death_animation = true, -- animate the pet's death, set to false to feel less guilt -- currently no animations are available
popup = { -- popup options, try changing these if you see a rectangle around the pets
width = "30%", -- can be a string with percentage like "45%" or a number of columns like 45
winblend = 100, -- winblend value - see :h 'winblend' - only used if avoid_statusline is false
hl = { Normal = "Normal" }, -- hl is only set if avoid_statusline is true, you can put any hl group instead of "Normal"
avoid_statusline = true, -- if winblend is 100 then the popup is invisible and covers the statusline, if that
-- doesn't work for you then set this to true and the popup will use hl and will be spawned above the statusline (hopefully)
}
})
end
}

View File

@ -0,0 +1,54 @@
return {
"rest-nvim/rest.nvim",
dependencies = { { "nvim-lua/plenary.nvim" } },
config = function()
require("rest-nvim").setup({
-- Open request results in a horizontal split
result_split_horizontal = false,
-- Keep the http file buffer above|left when split horizontal|vertical
result_split_in_place = false,
-- stay in current windows (.http file) or change to results window (default)
stay_in_current_window_after_split = false,
-- Skip SSL verification, useful for unknown certificates
skip_ssl_verification = false,
-- Encode URL before making request
encode_url = true,
-- Highlight request on run
highlight = {
enabled = true,
timeout = 150,
},
result = {
-- toggle showing URL, HTTP info, headers at top the of result window
show_url = true,
-- show the generated curl command in case you want to launch
-- the same request via the terminal (can be verbose)
show_curl_command = false,
show_http_info = true,
show_headers = true,
-- table of curl `--write-out` variables or false if disabled
-- for more granular control see Statistics Spec
show_statistics = false,
-- executables or functions for formatting response body [optional]
-- set them to false if you want to disable them
formatters = {
json = "jq",
html = function(body)
return vim.fn.system({"tidy", "-i", "-q", "-"}, body)
end
},
},
-- Jump to request line on run
jump_to_request = false,
env_file = '.env',
-- for telescope select
env_pattern = "\\.env$",
env_edit_command = "tabedit",
custom_dynamic_variables = {},
yank_dry_run = true,
search_back = true,
})
vim.keymap.set("n", "<leader>r", "<Plug>RestNvim")
end
}

View File

@ -0,0 +1,10 @@
return {
"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
}

View File

@ -0,0 +1,4 @@
return {
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make'
}

View File

@ -0,0 +1,29 @@
return {
{
'nvim-telescope/telescope-ui-select.nvim'
},
{
'nvim-telescope/telescope.nvim',
dependencies = {'nvim-lua/plenary.nvim'},
lazy = false,
keys = {
{ "<leader>ff", "<cmd>Telescope find_files<cr>" },
{ "<leader>fb", "<cmd>Telescope buffers<cr>" },
{ "<leader>fo", "<cmd>Telescope oldfiles<cr>" },
{ "<leader>fg", "<cmd>Telescope live_grep<cr>" },
{ "<leader>fc", "<cmd>Telescope commands<cr>" }
},
config = function()
require("telescope").setup {
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown {
}
}
}
}
-- require('telescope').load_extension('fzf')
require("telescope").load_extension("ui-select")
end
}
}

View File

@ -0,0 +1,3 @@
return {
'xiyaowong/transparent.nvim'
}

View File

@ -0,0 +1,79 @@
return {
{
'nvim-treesitter/nvim-treesitter',
config = function()
require('nvim-treesitter.configs').setup({
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
auto_install = true,
-- indent module
indent = { enable = true },
-- highlight module
highlight = { enable = true },
-- auto close tags in html/jsx/tsx
autotag = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<CR>',
scope_incremental = '<CR>',
node_incremental = '<TAB>',
node_decremental = '<S-TAB>',
},
},
-- text object selection
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
-- You can also use captures from other query groups like `locals.scm`
["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
},
-- You can choose the select mode (default is charwise 'v')
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * method: eg 'v' or 'o'
-- and should return the mode ('v', 'V', or '<c-v>') or a table
-- mapping query_strings to modes.
selection_modes = {
['@parameter.outer'] = 'v', -- charwise
['@function.outer'] = 'V', -- linewise
['@class.outer'] = '<c-v>', -- blockwise
},
-- If you set this to `true` (default is `false`) then any textobject is
-- extended to include preceding or succeeding whitespace. Succeeding
-- whitespace has priority in order to act similarly to eg the built-in
-- `ap`.
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * selection_mode: eg 'v'
-- and should return true of false
include_surrounding_whitespace = true,
},
},
})
end
},
{
'nvim-treesitter/nvim-treesitter-textobjects'
},
}

View File

@ -0,0 +1,6 @@
return {
'mbbill/undotree',
keys = {
{ "<leader>u", vim.cmd.UndotreeToggle, desc = "Undotree" },
}
}

View File

@ -0,0 +1 @@
return { 'nvim-tree/nvim-web-devicons' }