From e691426711f06d991131269a8cd9537c5d40a236 Mon Sep 17 00:00:00 2001 From: Eduardo Cueto-Mendoza Date: Mon, 17 Jul 2023 18:18:14 +0100 Subject: [PATCH] Added a more sane configuration for neovim --- after/plugin/colors.lua | 11 +++++ after/plugin/fugitive.lua | 1 + after/plugin/harpoon.lua | 10 ++++ after/plugin/lsp.lua | 21 +++++++++ after/plugin/telescope.lua | 6 +++ after/plugin/treesitter.lua | 24 ++++++++++ after/plugin/undotree.lua | 1 + init.lua | 1 + lua/eddie/init.lua | 3 ++ lua/eddie/keymaps.lua | 78 +++++++++++++++++++++++++++++++ lua/eddie/options.lua | 91 +++++++++++++++++++++++++++++++++++++ lua/eddie/packer.lua | 64 ++++++++++++++++++++++++++ 12 files changed, 311 insertions(+) create mode 100644 after/plugin/colors.lua create mode 100644 after/plugin/fugitive.lua create mode 100644 after/plugin/harpoon.lua create mode 100644 after/plugin/lsp.lua create mode 100644 after/plugin/telescope.lua create mode 100644 after/plugin/treesitter.lua create mode 100644 after/plugin/undotree.lua create mode 100644 init.lua create mode 100644 lua/eddie/init.lua create mode 100644 lua/eddie/keymaps.lua create mode 100644 lua/eddie/options.lua create mode 100644 lua/eddie/packer.lua diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua new file mode 100644 index 0000000..92e796d --- /dev/null +++ b/after/plugin/colors.lua @@ -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() diff --git a/after/plugin/fugitive.lua b/after/plugin/fugitive.lua new file mode 100644 index 0000000..80c9070 --- /dev/null +++ b/after/plugin/fugitive.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "gs", vim.cmd.Git) diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua new file mode 100644 index 0000000..eed35ed --- /dev/null +++ b/after/plugin/harpoon.lua @@ -0,0 +1,10 @@ +local mark = require("harpoon.mark") +local ui = require("harpoon.ui") + +vim.keymap.set("n", "a", mark.add_file) +vim.keymap.set("n", "", ui.toggle_quick_menu) + +vim.keymap.set("n", "", function() ui.nav_file(1) end) +vim.keymap.set("n", "", function() ui.nav_file(2) end) +vim.keymap.set("n", "", function() ui.nav_file(3) end) +vim.keymap.set("n", "", function() ui.nav_file(4) end) diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua new file mode 100644 index 0000000..c4bdf0a --- /dev/null +++ b/after/plugin/lsp.lua @@ -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() diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua new file mode 100644 index 0000000..1c6b836 --- /dev/null +++ b/after/plugin/telescope.lua @@ -0,0 +1,6 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'pf', builtin.find_files, {}) +vim.keymap.set('n', '', builtin.git_files, {}) +vim.keymap.set('n', 'ps', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) +end) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 0000000..199ca37 --- /dev/null +++ b/after/plugin/treesitter.lua @@ -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, + }, +} diff --git a/after/plugin/undotree.lua b/after/plugin/undotree.lua new file mode 100644 index 0000000..a346462 --- /dev/null +++ b/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..303c636 --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require("eddie") diff --git a/lua/eddie/init.lua b/lua/eddie/init.lua new file mode 100644 index 0000000..d85cbcf --- /dev/null +++ b/lua/eddie/init.lua @@ -0,0 +1,3 @@ +require("eddie.keymaps") +require("eddie.options") + diff --git a/lua/eddie/keymaps.lua b/lua/eddie/keymaps.lua new file mode 100644 index 0000000..4025688 --- /dev/null +++ b/lua/eddie/keymaps.lua @@ -0,0 +1,78 @@ +----------------- +-- Normal mode -- +----------------- + +-- Hint: see `:h vim.map.set()` +-- Better window navigation +vim.keymap.set("n", "", "h", opts) +vim.keymap.set("n", "", "j", opts) +vim.keymap.set("n", "", "k", opts) +vim.keymap.set("n", "", "l", opts) + +-- Resize with arrows +-- delta: 2 lines +vim.keymap.set("n", "", ":resize -2", opts) +vim.keymap.set("n", "", ":resize +2", opts) +vim.keymap.set("n", "", ":vertical resize -2", opts) +vim.keymap.set("n", "", ":vertical resize +2", opts) + +-- open File Explorer +vim.keymap.set("n", "pv", vim.cmd.Ex) + +-- Navigate buffers +vim.keymap.set("n", "", ":bnext", opts) +vim.keymap.set("n", "", ":bprevious", opts) + +-- Telescope +local builtin = require("telescope.builtin") +--vim.keymap.set("n", "pf", builtin.find_files, {}) +--vim.keymap.set("n", "", builtin.git_files, {}) +--vim.keymap.set("n", "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", "a", mark.add_file) +vim.keymap.set("n", "", ui.toggle_quick_menu) + +vim.keymap.set("n", "", function () ui.nav_file(1) end) +vim.keymap.set("n", "", function () ui.nav_file(2) end) +vim.keymap.set("n", "", function () ui.nav_file(3) end) +vim.keymap.set("n", "", function () ui.nav_file(4) end) + +-- Undotree +vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + +-- Fugitive +vim.keymap.set("n", "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", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- Don't loose buffer +vim.keymap.set("x", "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) + +-- Move text on visual mode +vim.keymap.set("v", "J", ":m '>+1gv=gv", opts) +vim.keymap.set("v", "K", ":m '<-2gv=gv", opts) + + + + diff --git a/lua/eddie/options.lua b/lua/eddie/options.lua new file mode 100644 index 0000000..6cffa54 --- /dev/null +++ b/lua/eddie/options.lua @@ -0,0 +1,91 @@ +-- Hint: use `:h