feat: Neovim config

This commit is contained in:
Michael Yockey
2024-02-29 09:30:15 -05:00
parent e793368e27
commit b238b57409
11 changed files with 168 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
function ColorMyPencils(color)
color = color or 'flexoki-light'
vim.cmd.colorscheme(color)
end
ColorMyPencils()

View File

@@ -0,0 +1,48 @@
local lsp = require('lsp-zero')
local mason = require('mason')
local mason_lspconfig = require('mason-lspconfig')
mason.setup({})
mason_lspconfig.setup({
ensure_installed = {
'ruby_ls',
'tsserver',
'lua_ls',
},
handlers = {
lsp.default_setup,
lua_ls = function()
require('lspconfig').lua_ls.setup({
settings = {
Lua = {
diagnostics = {
globals = {
'vim',
'require',
}
}
}
}
})
end,
},
})
lsp.on_attach(function(_client, bufnr)
local opts = { buffer = bufnr, remap = false }
lsp.default_keymaps(opts)
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('n', '<C-h>', function() vim.lsp.buf.signature_help() end, opts)
end)
lsp.setup()

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,21 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "lua", "ruby", "javascript", "typescript" },
-- 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 @@
require('yock')

View File

@@ -0,0 +1,3 @@
require('yock.pckr')
require('yock.remap')
require('yock.set')

View File

@@ -0,0 +1,41 @@
local function bootstrap_pckr()
local pckr_path = vim.fn.stdpath('data') .. 'pckr/pckr.nvim'
if not vim.loop.fs_stat(pckr_path) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/lewis6991/pckr.nvim',
pckr_path
})
end
vim.opt.rtp:prepend(pckr_path)
end
bootstrap_pckr()
require('pckr').add{
{ 'nvim-telescope/telescope.nvim', requires = { 'nvim-lua/plenary.nvim' } },
{ 'kepano/flexoki-neovim' },
{ 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' },
{ 'mbbill/undotree' },
{
'VonHeikemen/lsp-zero.nvim',
requires = {
{ 'neovim/nvim-lspconfig' },
{ 'williamboman/mason.nvim' },
{ 'williamboman/mason-lspconfig.nvim' },
{ 'hrsh7th/nvim-cmp' },
{ 'hrsh7th/cmp-nvim-lsp' },
{ 'L3MON4D3/LuaSnip' },
{ 'hrsh7th/cmp-path' },
{ 'hrsh7th/cmp-nvim-lua' },
{ 'hrsh7th/cmp-buffer' },
{ 'rafamadriz/friendly-snippets' },
{ 'saadparwaiz1/cmp_luasnip' },
},
},
{ 'zbirenbaum/copilot-cmp', requires = { 'github/copilot.lua' } },
}

View File

@@ -0,0 +1,14 @@
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
-- Move highlights
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")
-- Paste over without copying what is under
vim.keymap.set('x', '<leader>p', "\"_dP")
-- Copy to system clipboard
vim.keymap.set('n', '<leader>y', "\"+y")
vim.keymap.set('v', '<leader>y', "\"+y")
vim.keymap.set('n', '<leader>Y', "\"+Y")

View File

@@ -0,0 +1,26 @@
vim.opt.nu = true
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.shiftwidth = 2
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') .. '/.nvim/undodir'
vim.opt.undofile = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 8
vim.opt.signcolumn = 'yes'
vim.opt.colorcolumn = '120'
vim.g.mapleader = '\\'