new neovim config

This commit is contained in:
Cynthia Foxwell 2023-05-25 21:48:59 -06:00
parent 81b6091ef6
commit 4c2dcb4be1
16 changed files with 363 additions and 0 deletions

View file

@ -0,0 +1,54 @@
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
-- Move to previous/next
map("n", "<A-,>", "<Cmd>BufferPrevious<CR>", opts)
map("n", "<A-.>", "<Cmd>BufferNext<CR>", opts)
-- Re-order to previous/next
map("n", "<A-<>", "<Cmd>BufferMovePrevious<CR>", opts)
map("n", "<A->>", "<Cmd>BufferMoveNext<CR>", opts)
-- Goto buffer in position...
map("n", "<A-1>", "<Cmd>BufferGoto 1<CR>", opts)
map("n", "<A-2>", "<Cmd>BufferGoto 2<CR>", opts)
map("n", "<A-3>", "<Cmd>BufferGoto 3<CR>", opts)
map("n", "<A-4>", "<Cmd>BufferGoto 4<CR>", opts)
map("n", "<A-5>", "<Cmd>BufferGoto 5<CR>", opts)
map("n", "<A-6>", "<Cmd>BufferGoto 6<CR>", opts)
map("n", "<A-7>", "<Cmd>BufferGoto 7<CR>", opts)
map("n", "<A-8>", "<Cmd>BufferGoto 8<CR>", opts)
map("n", "<A-9>", "<Cmd>BufferGoto 9<CR>", opts)
map("n", "<A-0>", "<Cmd>BufferLast<CR>", opts)
-- Pin/unpin buffer
map("n", "<A-p>", "<Cmd>BufferPin<CR>", opts)
-- Close buffer
map("n", "<A-c>", "<Cmd>BufferClose<CR>", opts)
vim.g.barbar_auto_setup = false
local barbar = require("barbar")
barbar.setup({
animation = false,
auto_hide = true,
tabpages = true,
clickable = true,
focus_on_close = "previous",
icons = {
gitsigns = {
added = {enabled = true, icon = '+'},
changed = {enabled = true, icon = '~'},
deleted = {enabled = true, icon = '-'},
},
filetype = {
custom_colors = false,
enabled = false,
},
separator = {left = "", right = ""},
modified = {button = ""},
pinned = {button = "", filename = true},
inactive = {button = "x"},
button = "x",
},
sidebar_filetypes = {
NvimTree = true,
undotree = {text = "undotree"},
},
})

View file

@ -0,0 +1,14 @@
require("indent_blankline").setup({
char = "",
space_char_blankline = " ",
char_blankline = " ",
char_highlight_list = {
"IndentBlanklineIndent1",
"IndentBlanklineIndent2",
"IndentBlanklineIndent3",
"IndentBlanklineIndent4",
},
show_current_context = true,
show_current_context_start = true,
})

View file

@ -0,0 +1,42 @@
vim.cmd("colorscheme lena")
vim.cmd("highlight IndentBlanklineIndent1 ctermfg=11 cterm=nocombine")
vim.cmd("highlight IndentBlanklineIndent2 ctermfg=10 cterm=nocombine")
vim.cmd("highlight IndentBlanklineIndent3 ctermfg=13 cterm=nocombine")
vim.cmd("highlight IndentBlanklineIndent4 ctermfg=12 cterm=nocombine")
vim.cmd("hi Normal ctermbg=NONE")
vim.cmd("hi LineNr ctermfg=7")
vim.cmd("hi CursorLineNr ctermfg=1 ctermbg=0")
vim.cmd("hi CursorLine cterm=NONE ctermfg=NONE ctermbg=0")
vim.cmd("hi StatusLine ctermfg=5 ctermbg=8 cterm=NONE")
vim.cmd("hi StatusLineNC ctermfg=7 ctermbg=0 cterm=NONE")
vim.cmd("hi VertSplit ctermbg=0 ctermfg=0")
vim.cmd("hi ExtraWhitespace ctermbg=1")
vim.cmd("hi SignColumn ctermbg=8")
vim.cmd("hi BufferCurrent ctermfg=5 ctermbg=NONE")
vim.cmd("hi BufferCurrentIndex ctermfg=5 ctermbg=NONE")
vim.cmd("hi BufferCurrentMod ctermfg=9 ctermbg=NONE")
vim.cmd("hi BufferCurrentSign ctermfg=5 ctermbg=NONE")
vim.cmd("hi BufferCurrentTarget ctermfg=5 ctermbg=NONE")
vim.cmd("hi BufferVisible ctermfg=7 ctermbg=NONE")
vim.cmd("hi BufferVisibleIndex ctermfg=7 ctermbg=NONE")
vim.cmd("hi BufferVisibleMod ctermfg=9 ctermbg=NONE")
vim.cmd("hi BufferVisibleSign ctermfg=7 ctermbg=NONE")
vim.cmd("hi BufferVisibleTarget ctermfg=7 ctermbg=NONE")
vim.cmd("hi BufferInactive ctermfg=7 ctermbg=0")
vim.cmd("hi BufferInactiveIndex ctermfg=5 ctermbg=0")
vim.cmd("hi BufferInactiveMod ctermfg=1 ctermbg=0")
vim.cmd("hi BufferInactiveSign ctermfg=10 ctermbg=0")
vim.cmd("hi BufferInactiveTarget ctermfg=11 ctermbg=0")
vim.cmd("hi BufferTabpages ctermfg=7 ctermbg=0")
vim.cmd("hi BufferTabpageFill ctermfg=7 ctermbg=0")
vim.cmd("hi BufferOffset ctermfg=0 ctermbg=0")
vim.cmd("hi! link SignColumn LineNr")
vim.cmd("hi LspDiagnosticsDefaultHint ctermfg=6")
vim.cmd("hi LspDiagnosticsDefaultError ctermfg=1")
vim.cmd("hi LspDiagnosticsDefaultWarning ctermfg=3")
vim.cmd("hi LspDiagnosticsDefaultInformation ctermfg=7")

View file

@ -0,0 +1 @@
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)

View file

@ -0,0 +1,58 @@
local lsp = require("lsp-zero")
lsp.preset("recommended")
lsp.ensure_installed({
"eslint",
"rust_analyzer",
})
lsp.nvim_workspace()
local cmp = require("cmp")
local cmp_select = {behavior = cmp.SelectBehavior.Select}
local cmp_mappings = lsp.defaults.cmp_mappings({
["<C-F>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-f>"] = cmp.mapping.select_next_item(cmp_select),
["<CR>"] = cmp.mapping.confirm({select = true}),
["<C-Space>"] = cmp.mapping.complete(),
["<Esc>"] = cmp.mapping.abort(),
})
cmp_mappings["<Tab>"] = nil
cmp_mappings["<S-Tab>"] = nil
lsp.setup_nvim_cmp({
mapping = cmp_mappings,
})
lsp.set_preferences({
suggest_lsp_servers = false,
sign_icons = {
error = "E",
warn = "W",
hint = "H",
info = "I",
},
})
lsp.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", "K", function() vim.lsp.buf.hover() end, opts)
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
vim.keymap.set("n", "<leader>vd", 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>vca", function() vim.lsp.buf.code_action() end, opts)
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
end)
lsp.setup_servers({"eslint"})
lsp.setup()
vim.diagnostic.config({
virtual_text = true
})

View file

@ -0,0 +1,6 @@
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
vim.keymap.set('n', '<leader>ps', function()
builtin.grep_string({search = vim.fn.input("Grep > ")})
end)

View file

@ -0,0 +1,36 @@
require("nvim-tree").setup({
actions = {
open_file = {
quit_on_open = true,
},
},
renderer = {
indent_markers = {
enable = true,
},
icons = {
symlink_arrow = " -> ",
show = {
file = false,
folder = false,
},
glyphs = {
folder = {
arrow_closed = "+",
arrow_open = "-",
},
git = {
unstaged = "U",
staged = "S",
unmerged = "M",
renamed = "R",
untracked = "+",
deleted = "-",
ignored = "I",
},
},
},
},
})
vim.keymap.set("n", "<leader>b", vim.cmd.NvimTreeToggle)

View file

@ -0,0 +1,21 @@
require'nvim-treesitter.configs'.setup({
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "javascript", "typescript", "rust", "c", "lua", "vim", "vimdoc", "query" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
highlight = {
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
})

View file

@ -0,0 +1 @@
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)

View file

@ -0,0 +1,4 @@
vim.g.better_whitespace_enable = true
vim.g.strip_whitespace_on_save = true
vim.cmd("hi ExtraWhitespace ctermbg=9")

4
common/nvim/init.lua Normal file
View file

@ -0,0 +1,4 @@
vim.g.loaded_netrw = 1
vim.g.loaded_netwrPlugin = 1
require("cc")

View file

@ -0,0 +1,3 @@
require("cc.packer")
require("cc.remap")
require("cc.set")

View file

@ -0,0 +1,48 @@
vim.cmd("packadd packer.nvim")
local packer = require("packer")
return packer.startup(function(use)
use("wbthomason/packer.nvim")
use({
"nvim-telescope/telescope.nvim",
tag = "0.1.1",
requires = {
{"nvim-lua/plenary.nvim"},
},
})
use(
"nvim-treesitter/nvim-treesitter",
{run = ":TSUpdate"}
)
use("theprimeagen/harpoon")
use("mbbill/undotree")
use("tpope/vim-fugitive")
use({
"VonHeikemen/lsp-zero.nvim",
branch = "v2.x",
requires = {
-- LSP Support
{"neovim/nvim-lspconfig"}, -- Required
{ -- Optional
"williamboman/mason.nvim",
run = function()
pcall(vim.cmd, "MasonUpdate")
end,
},
{"williamboman/mason-lspconfig.nvim"}, -- Optional
-- Autocompletion
{"hrsh7th/nvim-cmp"}, -- Required
{"hrsh7th/cmp-nvim-lsp"}, -- Required
{"L3MON4D3/LuaSnip"}, -- Required
},
})
use("lukas-reineke/indent-blankline.nvim")
use("romgrk/barbar.nvim")
use("ntpeters/vim-better-whitespace")
use("nvim-tree/nvim-tree.lua")
end)

View file

@ -0,0 +1,41 @@
vim.g.mapleader = " "
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>")
vim.keymap.set("!", "<C-f>", "<C-i>")
vim.keymap.set("!", "<C-g>", "<C-d>")
vim.keymap.set("i", "<Tab>", "<Esc>")
vim.keymap.set("c", "<Tab>", "<C-c>")
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("v", "<S-Down>", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "<S-Up>", ":m '<-2<CR>gv=gv")
vim.keymap.set("n", "J", "mzJ`z")
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", "<leader>f", function()
vim.lsp.buf.format()
end)
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
vim.keymap.set("n", "<leader><leader>", function()
vim.cmd("so")
end)
vim.keymap.set("n", "<leader>vpp", function()
local dir = vim.call("stdpath", "config")
vim.cmd("e " .. dir .. "/lua/cc/packer.lua")
end)
vim.keymap.set("n", "<leader>vps", "<cmd>PackerSync<CR>")

View file

@ -0,0 +1,30 @@
vim.opt.termguicolors = false
vim.opt.fileformat = "unix"
vim.opt.fileformats = {"unix", "dos"}
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.cul = true
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.list = true
vim.opt.listchars:append("space:⋅")
vim.opt.listchars:append("eol:↴")
vim.opt.fillchars:append("vert:▎")
vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.updatetime = 50
vim.opt.colorcolumn = "80"
vim.g.ackprg = "ag --vimgrep"