Copy NVim configuration from anthdm

This commit is contained in:
Fabio Scotto di Santolo
2023-04-04 16:41:38 +02:00
parent b905d0e916
commit e2b01cff4e
3 changed files with 391 additions and 0 deletions

3
.nvim/README.md Normal file
View File

@@ -0,0 +1,3 @@
# GG's nvim configuration
Simple, yet effective <3

173
.nvim/init.lua Normal file
View File

@@ -0,0 +1,173 @@
print("Welcome Anthony! How are you doing today?")
vim.g.mapleader = " "
require("packer").startup(function(use)
use { "wbthomason/packer.nvim" }
use { "ellisonleao/gruvbox.nvim" }
use('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'})
use {
'nvim-telescope/telescope.nvim', tag = '0.1.1',
requires = { {'nvim-lua/plenary.nvim'} }
}
use {
'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
}
use { "fatih/vim-go" }
use {
'VonHeikemen/lsp-zero.nvim',
branch = 'v1.x',
requires = {
{'neovim/nvim-lspconfig'}, -- Required
{'williamboman/mason.nvim'}, -- Optional
{'williamboman/mason-lspconfig.nvim'}, -- Optional
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'hrsh7th/cmp-buffer'}, -- Optional
{'hrsh7th/cmp-path'}, -- Optional
{'saadparwaiz1/cmp_luasnip'}, -- Optional
{'hrsh7th/cmp-nvim-lua'}, -- Optional
{'L3MON4D3/LuaSnip'}, -- Required
{'rafamadriz/friendly-snippets'}, -- Optional
},
use {"akinsho/toggleterm.nvim", tag = '*' },
use "jhlgns/naysayer88.vim",
use "terrortylor/nvim-comment",
use "CreaturePhil/vim-handmade-hero"
}
end)
-- some
vim.keymap.set("n", "<M-b>", ":Ex<CR>")
-- split screen and navigation
vim.keymap.set("n", "<leader>v", ":vsplit<CR><C-w>l", { noremap = true })
vim.keymap.set("n", "<leader>h", ":wincmd h<CR>", { noremap = true })
vim.keymap.set("n", "<leader>l", ":wincmd l<CR>", { noremap = true })
-- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>f', function()
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
vim.keymap.set('n', '<leader>p', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<M-p>', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
-- TREESITTER
require'nvim-treesitter.configs'.setup {
ensure_installed = {"c", "lua", "vim", "go", "javascript", "typescript", "rust"},
highlight = {
enable = true,
}
}
-- GRUVBOX
require("gruvbox").setup({
contrast = "hard",
palette_overrides = {
gray = "#2ea542",
}
})
-- LUALINE
require("lualine").setup{
options = {
icons_enabled = false,
theme = "onedark",
component_separators = "|",
section_separators = "",
},
}
-- LSP
local lsp = require("lsp-zero")
lsp.preset("recommended")
lsp.ensure_installed({
"tsserver",
"gopls",
"eslint",
"rust_analyzer",
})
lsp.set_preferences({
sign_icons = {}
})
lsp.on_attach(function(client, bufnr)
local opts = {buffer = bufnr, remap = false}
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
end)
lsp.setup()
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
signs = false,
virtual_text = true,
underline = false,
}
)
-- COMMENT
require("nvim_comment").setup({
operator_mapping = "<leader>/"
})
-- TERMINAL SETUP
require("toggleterm").setup{
direction = "horizontal",
size = 15,
open_mapping = [[<M-j>]]
}
-- COLORSCHEME
vim.cmd("colorscheme gruvbox")
-- Adding the same comment color in each theme
vim.cmd([[
augroup CustomCommentCollor
autocmd!
autocmd VimEnter * hi Comment guifg=#2ea542
augroup END
]])
-- Disable annoying match brackets and all the jaz
vim.cmd([[
augroup CustomHI
autocmd!
autocmd VimEnter * NoMatchParen
augroup END
]])
vim.o.background = "dark"
vim.keymap.set("i", "jj", "<Esc>")
vim.opt.guicursor = "i:block"
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.number = false
vim.opt.relativenumber = true
vim.opt.swapfile = false
vim.o.hlsearch = true
vim.o.mouse = 'a'
vim.o.breakindent = true
vim.o.undofile = true
vim.o.ignorecase = true
vim.o.updatetime = 250
vim.o.timeout = true
vim.o.timeoutlen = 300
--vim.o.completeopt = 'menuone,noselect'
vim.o.termguicolors = true

View File

@@ -0,0 +1,215 @@
-- Automatically generated packer.nvim plugin loader code
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end
vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
_G._packer = _G._packer or {}
_G._packer.inside_compile = true
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
if threshold then
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
end
_G._packer.profile_output = results
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/anthdm/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/anthdm/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/anthdm/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/anthdm/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/anthdm/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
LuaSnip = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/LuaSnip",
url = "https://github.com/L3MON4D3/LuaSnip"
},
["cmp-buffer"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/cmp-buffer",
url = "https://github.com/hrsh7th/cmp-buffer"
},
["cmp-nvim-lsp"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
},
["cmp-nvim-lua"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua",
url = "https://github.com/hrsh7th/cmp-nvim-lua"
},
["cmp-path"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/cmp-path",
url = "https://github.com/hrsh7th/cmp-path"
},
cmp_luasnip = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/cmp_luasnip",
url = "https://github.com/saadparwaiz1/cmp_luasnip"
},
["friendly-snippets"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/friendly-snippets",
url = "https://github.com/rafamadriz/friendly-snippets"
},
["gruvbox.nvim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/gruvbox.nvim",
url = "https://github.com/ellisonleao/gruvbox.nvim"
},
["lsp-zero.nvim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim",
url = "https://github.com/VonHeikemen/lsp-zero.nvim"
},
["lualine.nvim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/lualine.nvim",
url = "https://github.com/nvim-lualine/lualine.nvim"
},
["mason-lspconfig.nvim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim",
url = "https://github.com/williamboman/mason-lspconfig.nvim"
},
["mason.nvim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/mason.nvim",
url = "https://github.com/williamboman/mason.nvim"
},
["naysayer88.vim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/naysayer88.vim",
url = "https://github.com/jhlgns/naysayer88.vim"
},
["nvim-cmp"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/nvim-cmp",
url = "https://github.com/hrsh7th/nvim-cmp"
},
["nvim-comment"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/nvim-comment",
url = "https://github.com/terrortylor/nvim-comment"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["nvim-treesitter"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["nvim-web-devicons"] = {
loaded = false,
needs_bufread = false,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/opt/nvim-web-devicons",
url = "https://github.com/kyazdani42/nvim-web-devicons"
},
["packer.nvim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["plenary.nvim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["telescope.nvim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
["toggleterm.nvim"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/toggleterm.nvim",
url = "https://github.com/akinsho/toggleterm.nvim"
},
["vim-go"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/vim-go",
url = "https://github.com/fatih/vim-go"
},
["vim-handmade-hero"] = {
loaded = true,
path = "/home/anthdm/.local/share/nvim/site/pack/packer/start/vim-handmade-hero",
url = "https://github.com/CreaturePhil/vim-handmade-hero"
}
}
time([[Defining packer_plugins]], false)
_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then
vim.cmd("doautocmd BufRead")
end
_G._packer.needs_bufread = false
if should_profile then save_profiles() end
end)
if not no_errors then
error_msg = error_msg:gsub('"', '\\"')
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end