Added a more sane configuration for neovim

This commit is contained in:
Eduardo Cueto-Mendoza 2023-07-17 18:18:14 +01:00
parent 0e406eeeca
commit e691426711
12 changed files with 311 additions and 0 deletions

11
after/plugin/colors.lua Normal file
View File

@ -0,0 +1,11 @@
function ColorMyPencils(color)
color = color or "rose-pine"
vim.cmd.colorscheme(color)
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
end
ColorMyPencils()

View File

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

10
after/plugin/harpoon.lua Normal file
View File

@ -0,0 +1,10 @@
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<C-h>", function() ui.nav_file(1) end)
vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end)
vim.keymap.set("n", "<C-n>", function() ui.nav_file(3) end)
vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end)

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

@ -0,0 +1,21 @@
local lsp = require('lsp-zero').preset({})
lsp.on_attach(function(client, bufnr)
lsp.default_keymaps({buffer = bufnr})
end)
-- Language servers
lsp.ensure_installed({
-- Replace these with whatever servers you want to install
'bashls',
'julials',
'lua_ls',
'pylsp',
'texlab',
'zls'
})
-- (Optional) Configure lua language server for neovim
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
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,24 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "c", "julia", "latex", "lua", "python", "query", "vim", "vimdoc", "zig" },
-- 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,
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
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)

1
init.lua Normal file
View File

@ -0,0 +1 @@
require("eddie")

3
lua/eddie/init.lua Normal file
View File

@ -0,0 +1,3 @@
require("eddie.keymaps")
require("eddie.options")

78
lua/eddie/keymaps.lua Normal file
View File

@ -0,0 +1,78 @@
-----------------
-- Normal mode --
-----------------
-- Hint: see `:h vim.map.set()`
-- Better window navigation
vim.keymap.set("n", "<C-h>", "<C-w>h", opts)
vim.keymap.set("n", "<C-j>", "<C-w>j", opts)
vim.keymap.set("n", "<C-k>", "<C-w>k", opts)
vim.keymap.set("n", "<C-l>", "<C-w>l", opts)
-- Resize with arrows
-- delta: 2 lines
vim.keymap.set("n", "<C-Up>", ":resize -2<CR>", opts)
vim.keymap.set("n", "<C-Down>", ":resize +2<CR>", opts)
vim.keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", opts)
vim.keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", opts)
-- open File Explorer
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
-- Navigate buffers
vim.keymap.set("n", "<BS>", ":bnext<CR>", opts)
vim.keymap.set("n", "<S-TAB>", ":bprevious<CR>", opts)
-- Telescope
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)
-- Harpoon
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<C-h>", function () ui.nav_file(1) end)
vim.keymap.set("n", "<C-t>", function () ui.nav_file(2) end)
vim.keymap.set("n", "<C-n>", function () ui.nav_file(3) end)
vim.keymap.set("n", "<C-s>", function () ui.nav_file(4) end)
-- Undotree
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
-- Fugitive
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
-- Put line bellow in-front of line
vim.keymap.set("n", "J", "mzJ`z")
-- Keep cursor in the middle
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 loose buffer
vim.keymap.set("x", "<leader>p", "\"_dP")
-----------------
-- Visual mode --
-----------------
-- Hint: start visual mode with the same area as the previous area and the same mode
vim.keymap.set("v", "<", "<gv", opts)
vim.keymap.set("v", ">", ">gv", opts)
-- Move text on visual mode
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", opts)
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", opts)

91
lua/eddie/options.lua Normal file
View File

@ -0,0 +1,91 @@
-- Hint: use `:h <option>` to figure out the meaning if needed
vim.opt.clipboard = "unnamedplus" -- use system clipboard
vim.opt.completeopt = {"menu", "menuone", "noselect"}
vim.opt.mouse = "a" -- allow the mouse to be used in Nvim
-- Fonts
vim.opt.encoding="utf-8"
vim.opt.guifont = "Meslo LG M Bold for Powerline:h10"
-- Tab
vim.opt.tabstop = 4 -- number of visual spaces per TAB
vim.opt.softtabstop = 4 -- number of spacesin tab when editing
vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab
vim.opt.expandtab = true -- tabs are spaces, mainly because of python
-- UI config
vim.opt.number = true -- show absolute number
vim.opt.relativenumber = true -- add numbers to each line on the left side
vim.opt.cursorline = false -- highlight cursor line underneath the cursor horizontally
vim.opt.splitbelow = true -- open new vertical split bottom
vim.opt.splitright = true -- open new horizontal splits right
vim.opt.termguicolors = true -- enable 23-bit RGB color in the TUI
vim.opt.showmode = false -- we are experienced, wo don"t need the "-- INSERT --" mode hint
-- File recovery options
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
-- Color column
vim.opt.colorcolumn = "80"
-- Searching
vim.opt.incsearch = true -- search as characters are entered
vim.opt.hlsearch = false -- do not highlight matches
vim.opt.ignorecase = true -- ignore case in searches by default
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
-- Leader key
vim.g.mapleader = " "
--vim.g.maplocalleader = " "
vim.g.maplocalleader = "\\"
-- Undotree instead of swapfile
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
-- Airline
vim.g.airline_powerline_fonts = 1
-- Zig
vim.g.zig_fmt_autosave = 1
-- Set completeopt to have a better completion experience
--set completeopt=menuone,noinsert,noselect
vim.opt.completeopt = "menuone,noinsert,noselect"
-- Enable completions as you type
vim.g.completion_enable_auto_popup = 1
-- Python
vim.g.loaded_python_provider = 0
vim.g.python3_host_prog = "/usr/local/bin/python"
-- PDF Viewer:
-- http://manpages.ubuntu.com/manpages/trusty/man5/zathurarc.5.html
vim.g["vimtex_view_method"] = "zathura"
vim.g["vimtex_quickfix_mode"] =0
-- Ignore mappings
vim.g["vimtex_mappings_enabled"] = 1
-- Auto Indent
vim.g["vimtex_indent_enabled"] = 1
-- Syntax highlighting
vim.g["vimtex_syntax_enabled"] = 1
-- Error suppression:
-- https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt
vim.g["vimtex_log_ignore"] = ({
"Underfull",
"Overfull",
"specifier changed to",
"Token not allowed in a PDF string",
})
vim.g["vimtex_context_pdf_viewer"] = "zathura"

64
lua/eddie/packer.lua Normal file
View File

@ -0,0 +1,64 @@
-- This file can be loaded by calling `lua require('plugins')` from your init.vim
-- Only required if you have packer configured as `opt`
vim.cmd [[packadd packer.nvim]]
return require('packer').startup(function(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'
-- Fuzzy Finder
use {
'nvim-telescope/telescope.nvim', tag = '0.1.2',
-- or , branch = '0.1.x',
requires = { {'nvim-lua/plenary.nvim'} }
}
-- Colorscheme
use({
'rose-pine/neovim',
as = 'rose-pine',
config = function()
vim.cmd('colorscheme rose-pine')
end
})
-- Color Coloring
use({ 'nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' } })
use( 'nvim-treesitter/playground' )
-- Quick access to files
use( 'ThePrimeagen/harpoon' )
-- Recovery
use( 'mbbill/undotree' )
-- Git Status
use( 'tpope/vim-fugitive' )
-- Language Servers
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
}
}
-- :FixWhitespace
use "bronson/vim-trailing-whitespace"
end)