mirror of
https://github.com/danielepintore/dotfiles.git
synced 2026-06-15 20:25:13 +02:00
Added nvim configs
This commit is contained in:
1
.config/nvim/.gitignore
vendored
Normal file
1
.config/nvim/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/plugin
|
||||
1
.config/nvim/README.me
Normal file
1
.config/nvim/README.me
Normal file
@@ -0,0 +1 @@
|
||||
Remember to install packer to download all the plugins
|
||||
1
.config/nvim/after/plugin/codefmt.lua
Normal file
1
.config/nvim/after/plugin/codefmt.lua
Normal file
@@ -0,0 +1 @@
|
||||
vim.cmd(':Glaive codefmt prettier_executable="/home/daniele/.local/share/nvim/mason/bin/prettier"')
|
||||
9
.config/nvim/after/plugin/colorscheme.lua
Normal file
9
.config/nvim/after/plugin/colorscheme.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
function ActivateColorScheme(color)
|
||||
color = color or "catppuccin-mocha"
|
||||
vim.cmd.colorscheme(color)
|
||||
|
||||
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
||||
end
|
||||
|
||||
ActivateColorScheme()
|
||||
2
.config/nvim/after/plugin/copilot.lua
Normal file
2
.config/nvim/after/plugin/copilot.lua
Normal file
@@ -0,0 +1,2 @@
|
||||
-- Disable copilot by default
|
||||
vim.cmd(":Copilot disable")
|
||||
1
.config/nvim/after/plugin/fugitive.lua
Normal file
1
.config/nvim/after/plugin/fugitive.lua
Normal file
@@ -0,0 +1 @@
|
||||
vim.keymap.set("n", "<leader>gs", vim.cmd.Git);
|
||||
11
.config/nvim/after/plugin/harpoon.lua
Normal file
11
.config/nvim/after/plugin/harpoon.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
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-u>", function() ui.nav_file(1) end)
|
||||
vim.keymap.set("n", "<C-i>", function() ui.nav_file(2) end)
|
||||
vim.keymap.set("n", "<C-o>", function() ui.nav_file(3) end)
|
||||
-- Conflicts with find git files -- vim.keymap.set("n", "<C-p>", function() ui.nav_file(4) end)
|
||||
|
||||
89
.config/nvim/after/plugin/lsp.lua
Normal file
89
.config/nvim/after/plugin/lsp.lua
Normal file
@@ -0,0 +1,89 @@
|
||||
-- custom lsp per project
|
||||
require("neoconf").setup({
|
||||
-- override any of the default settings here
|
||||
plugins = {
|
||||
-- configures lsp clients with settings in the following order:
|
||||
-- - lua settings passed in lspconfig setup
|
||||
-- - global json settings
|
||||
-- - local json settings
|
||||
lspconfig = {
|
||||
enabled = true,
|
||||
},
|
||||
-- configures jsonls to get completion in .nvim.settings.json files
|
||||
jsonls = {
|
||||
enabled = true,
|
||||
-- only show completion in json settings for configured lsp servers
|
||||
configured_servers_only = false,
|
||||
},
|
||||
-- configures lua_ls to get completion of lspconfig server settings
|
||||
lua_ls = {
|
||||
-- by default, lua_ls annotations are only enabled in your neovim config directory
|
||||
enabled_for_neovim_config = true,
|
||||
-- explicitely enable adding annotations. Mostly relevant to put in your local .nvim.settings.json file
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
local lsp = require('lsp-zero')
|
||||
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
-- see :help lsp-zero-keybindings
|
||||
-- to learn the available actions
|
||||
lsp.default_keymaps({buffer = bufnr})
|
||||
end)
|
||||
|
||||
lsp.extend_cmp()
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({
|
||||
-- Replace the language servers listed here
|
||||
-- with the ones you want to install
|
||||
ensure_installed = {'eslint', 'tsserver', 'rust_analyzer', 'lua_ls', 'clangd',
|
||||
'volar', 'pylsp'},
|
||||
-- handlers = {
|
||||
-- lsp.default_setup,
|
||||
-- lua_ls = function()
|
||||
-- -- (Optional) Configure lua language server for neovim
|
||||
-- require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
||||
-- end,
|
||||
-- },
|
||||
})
|
||||
|
||||
require('mason-lspconfig').setup_handlers({
|
||||
function(server_name)
|
||||
local server_config = {}
|
||||
if require("neoconf").get(server_name .. ".disable") then
|
||||
return
|
||||
end
|
||||
if server_name == "volar" then
|
||||
server_config.filetypes = { 'vue', 'typescript', 'javascript' }
|
||||
end
|
||||
require('lspconfig')[server_name].setup(server_config)
|
||||
end,
|
||||
})
|
||||
|
||||
local cmp = require('cmp')
|
||||
local cmp_action = require('lsp-zero').cmp_action()
|
||||
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
-- `Enter` key to confirm completion
|
||||
['<CR>'] = cmp.mapping.confirm({select = false}),
|
||||
|
||||
-- Alt+Space to trigger completion menu
|
||||
['<M-Space>'] = cmp.mapping.complete(),
|
||||
|
||||
-- Tab to change item in completion menu
|
||||
['<Tab>'] = cmp_action.tab_complete(),
|
||||
-- Shift+Tab goes to the previus item in the completion menu
|
||||
['<S-Tab>'] = cmp_action.select_prev_or_fallback(),
|
||||
|
||||
-- Navigate between documentation
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-r>'] = cmp.mapping.scroll_docs(-4),
|
||||
}
|
||||
})
|
||||
|
||||
lsp.set_preferences({
|
||||
sign_icons = {}
|
||||
})
|
||||
6
.config/nvim/after/plugin/telescope.lua
Normal file
6
.config/nvim/after/plugin/telescope.lua
Normal 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)
|
||||
26
.config/nvim/after/plugin/treesitter.lua
Normal file
26
.config/nvim/after/plugin/treesitter.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
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,
|
||||
|
||||
-- List of parsers to ignore installing (for "all")
|
||||
-- ignore_install = { "javascript" },
|
||||
|
||||
---- 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,
|
||||
},
|
||||
}
|
||||
1
.config/nvim/after/plugin/undotree.lua
Normal file
1
.config/nvim/after/plugin/undotree.lua
Normal file
@@ -0,0 +1 @@
|
||||
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||
1
.config/nvim/init.lua
Normal file
1
.config/nvim/init.lua
Normal file
@@ -0,0 +1 @@
|
||||
require("configs")
|
||||
4
.config/nvim/lua/configs/init.lua
Normal file
4
.config/nvim/lua/configs/init.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
require("configs.remap")
|
||||
require("configs.packer")
|
||||
require("configs.set")
|
||||
require("configs.templates")
|
||||
89
.config/nvim/lua/configs/packer.lua
Normal file
89
.config/nvim/lua/configs/packer.lua
Normal file
@@ -0,0 +1,89 @@
|
||||
-- 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'
|
||||
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim', tag = '0.1.2',
|
||||
-- or , branch = '0.1.x',
|
||||
requires = { {'nvim-lua/plenary.nvim'} }
|
||||
}
|
||||
|
||||
use ({ "catppuccin/nvim", as = "catppuccin",
|
||||
config = function()
|
||||
require('catppuccin').setup({
|
||||
term_colors = false,
|
||||
transparent_background = true,
|
||||
styles = {
|
||||
comments = {},
|
||||
conditionals = {},
|
||||
loops = {},
|
||||
functions = {},
|
||||
keywords = {},
|
||||
strings = {},
|
||||
variables = {},
|
||||
numbers = {},
|
||||
booleans = {},
|
||||
properties = {},
|
||||
types = {},
|
||||
},
|
||||
|
||||
--[[color_overrides = {
|
||||
mocha = {
|
||||
base = "#000000",
|
||||
mantle = "#000000",
|
||||
crust = "#000000",
|
||||
},
|
||||
} ]]--
|
||||
})
|
||||
vim.cmd('colorscheme catppuccin')
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = ':TSUpdate'
|
||||
}
|
||||
|
||||
use("ThePrimeagen/harpoon")
|
||||
|
||||
use("mbbill/undotree")
|
||||
|
||||
use("tpope/vim-fugitive")
|
||||
|
||||
use {
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'dev-v3',
|
||||
requires = {
|
||||
--- Uncomment these if you want to manage LSP servers from neovim
|
||||
{'williamboman/mason.nvim'},
|
||||
{'williamboman/mason-lspconfig.nvim'},
|
||||
---
|
||||
|
||||
-- LSP Support
|
||||
{'neovim/nvim-lspconfig'},
|
||||
-- Autocompletion
|
||||
{'hrsh7th/nvim-cmp'},
|
||||
{'hrsh7th/cmp-nvim-lsp'},
|
||||
{'L3MON4D3/LuaSnip'},
|
||||
}
|
||||
}
|
||||
|
||||
-- Github copilot
|
||||
use("github/copilot.vim")
|
||||
|
||||
-- For navigation between vim and tmux
|
||||
use("christoomey/vim-tmux-navigator")
|
||||
|
||||
-- Per project custom lsp config
|
||||
use("folke/neoconf.nvim")
|
||||
|
||||
use("google/vim-maktaba")
|
||||
use("google/vim-codefmt")
|
||||
use("google/vim-glaive")
|
||||
end)
|
||||
60
.config/nvim/lua/configs/remap.lua
Normal file
60
.config/nvim/lua/configs/remap.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
vim.g.mapleader = " "
|
||||
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
|
||||
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":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")
|
||||
|
||||
-- greatest remap ever
|
||||
vim.keymap.set("x", "<leader>p", [["_dP]])
|
||||
|
||||
-- next greatest remap ever : asbjornHaland
|
||||
vim.keymap.set({"n", "v"}, "<leader>y", [["+y]])
|
||||
vim.keymap.set("n", "<leader>Y", [["+Y]])
|
||||
|
||||
vim.keymap.set({"n", "v"}, "<leader>d", [["_d]])
|
||||
|
||||
-- This is going to get me cancelled
|
||||
vim.keymap.set("i", "<C-c>", "<Esc>")
|
||||
|
||||
vim.keymap.set("n", "Q", "<nop>")
|
||||
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>")
|
||||
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format)
|
||||
vim.keymap.set("n", "<leader>qf", vim.lsp.buf.code_action)
|
||||
vim.keymap.set("n", "<leader>r", "e!")
|
||||
|
||||
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
|
||||
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
|
||||
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
|
||||
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
|
||||
|
||||
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
||||
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
|
||||
|
||||
vim.keymap.set("n", "<leader>vpp", "<cmd>e ~/.dotfiles/nvim/.config/nvim/lua/theprimeagen/packer.lua<CR>");
|
||||
vim.keymap.set("n", "<leader>mr", "<cmd>CellularAutomaton make_it_rain<CR>");
|
||||
|
||||
vim.keymap.set("n", "<leader><leader>", function()
|
||||
vim.cmd("so")
|
||||
end)
|
||||
|
||||
-- Redo by pressing r in normal mode
|
||||
vim.keymap.set("n", "r", "<C-r>")
|
||||
|
||||
-- Indent whole file with codefmt
|
||||
vim.keymap.set("n", "<leader>i", "<cmd>FormatCode<CR>")
|
||||
|
||||
-- Fast save
|
||||
vim.keymap.set("n", "<leader>w", "<cmd>w<CR>")
|
||||
vim.keymap.set("n", "<leader>q", "<cmd>q<CR>")
|
||||
|
||||
-- Copilot accept with C-j
|
||||
vim.g.copilot_no_tab_map = true
|
||||
vim.api.nvim_set_keymap("i", "<C-J>", 'copilot#Accept("<CR>")', { silent = true, expr = true })
|
||||
|
||||
|
||||
28
.config/nvim/lua/configs/set.lua
Normal file
28
.config/nvim/lua/configs/set.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
vim.opt.nu = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.softtabstop = 2
|
||||
vim.opt.shiftwidth = 2
|
||||
|
||||
vim.opt.smartindent = true
|
||||
|
||||
vim.opt.wrap = false
|
||||
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.vim/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.isfname:append("@-@")
|
||||
|
||||
vim.opt.updatetime = 50
|
||||
|
||||
vim.opt.colorcolumn = "80"
|
||||
4
.config/nvim/lua/configs/templates.lua
Normal file
4
.config/nvim/lua/configs/templates.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
vim.api.nvim_create_autocmd('BufNewFile', {
|
||||
pattern = "*.vue",
|
||||
command = "0r ~/.config/nvim/templates/vue.template"
|
||||
})
|
||||
8
.config/nvim/templates/vue.template
Normal file
8
.config/nvim/templates/vue.template
Normal file
@@ -0,0 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
|
||||
<template>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
Reference in New Issue
Block a user