nvim: cleanup configuration

This commit is contained in:
Marco Thomas
2023-03-04 23:46:12 +01:00
parent 36e5e4a4bb
commit dafe0ed68e
15 changed files with 134 additions and 310 deletions

View File

@@ -1,11 +1,12 @@
-- Make sure to update packer with `:PackerInstall` and `:PackerSync` -- NOTE: Make sure to update packer with `:PackerInstall` and `:PackerSync`
-- Treesitter with `:TSUpdate` after every nvim update.
-- LSP with `:LSPInstall`, log with `:LSPInfo` -- NOTE: Update Treesitter with `:TSUpdate` after every nvim update
--
-- Rollback possible with packer.nvim -- NOTE: Install LSP with `:LSPInstall`, log with `:LSPInfo`
-- Always create a snapshot BEFORE upgrading, so we can rollback if we find sth
-- `:PackerSnapshot YEAR-MONTH-DAY -- NOTE: Rollback possible with packer.nvim:
-- Location: ~/.cache/nvim/packer.nvim -- Always create a snapshot BEFORE upgrading `:PackerSnapshot YEAR-MONTH-DAY`
-- Location: ~/.cache/nvim/packer.nvim
-- This must be loaded first -- This must be loaded first
vim.cmd("set termguicolors") vim.cmd("set termguicolors")

View File

@@ -1,207 +0,0 @@
local M = {}
M.lspkind = {
Namespace = "",
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
Table = "",
Object = "",
Tag = "",
Array = "[]",
Boolean = "",
Number = "",
Null = "",
String = "",
Calendar = "",
Watch = "",
Package = "",
}
M.statusline_separators = {
default = {
left = "",
right = "",
},
round = {
left = "",
right = "",
},
block = {
left = "",
right = "",
},
arrow = {
left = "",
right = "",
},
}
M.devicons = {
default_icon = {
icon = "",
name = "Default",
},
c = {
icon = "",
name = "c",
},
css = {
icon = "",
name = "css",
},
deb = {
icon = "",
name = "deb",
},
Dockerfile = {
icon = "",
name = "Dockerfile",
},
html = {
icon = "",
name = "html",
},
jpeg = {
icon = "",
name = "jpeg",
},
jpg = {
icon = "",
name = "jpg",
},
js = {
icon = "",
name = "js",
},
kt = {
icon = "󱈙",
name = "kt",
},
lock = {
icon = "",
name = "lock",
},
lua = {
icon = "",
name = "lua",
},
mp3 = {
icon = "",
name = "mp3",
},
mp4 = {
icon = "",
name = "mp4",
},
out = {
icon = "",
name = "out",
},
png = {
icon = "",
name = "png",
},
py = {
icon = "",
name = "py",
},
["robots.txt"] = {
icon = "",
name = "robots",
},
toml = {
icon = "",
name = "toml",
},
ts = {
icon = "",
name = "ts",
},
ttf = {
icon = "",
name = "TrueTypeFont",
},
rb = {
icon = "",
name = "rb",
},
rpm = {
icon = "",
name = "rpm",
},
vue = {
icon = "",
name = "vue",
},
woff = {
icon = "",
name = "WebOpenFontFormat",
},
woff2 = {
icon = "",
name = "WebOpenFontFormat2",
},
xz = {
icon = "",
name = "xz",
},
zip = {
icon = "",
name = "zip",
},
}
return M

View File

@@ -24,23 +24,23 @@ telescope.setup({
} }
} }
}) })
map("n", "<C-f>", "<cmd> Telescope git_files <CR>", default_opts) -- Show files map("n", "<C-f>", "<cmd> Telescope git_files <CR>", default_opts)
map("n", "<C-s>", "<cmd> Telescope live_grep<CR>", default_opts) -- Grep through current directory map("n", "<C-s>", "<cmd> Telescope live_grep<CR>", default_opts)
map("n", "<C-k>", "<cmd> Telescope keymaps<CR>", default_opts) -- Show all keys map("n", "<C-k>", "<cmd> Telescope keymaps<CR>", default_opts)
-- Telescope + LSP -- LSP
map("n", "<leader>la", "<cmd> lua vim.lsp.buf.code_action()<CR>", default_opts) -- Apply LSP code action map("n", "<leader>la", "<cmd> lua vim.lsp.buf.code_action()<CR>", default_opts)
map("n", "<leader>ld", "<cmd> Telescope lsp_definitions<CR>", default_opts) -- Show all LSP definitions (or jump if only 1) map("n", "<leader>ld", "<cmd> Telescope lsp_definitions<CR>", default_opts)
map("n", "<leader>le", "<cmd> Telescope diagnostics<CR>", default_opts) -- Show errors and warnings map("n", "<leader>le", "<cmd> Telescope diagnostics<CR>", default_opts)
map("n", "<leader>lf", "<cmd> lua vim.lsp.buf.format {async = true }<CR>", default_opts) -- Format buffer with LSP map("n", "<leader>lf", "<cmd> lua vim.lsp.buf.format {async = true }<CR>", default_opts)
map("n", "<leader>lh", "<cmd> lua vim.lsp.buf.hover()<CR>", default_opts) -- Show info of symbol (double tap to enter) map("n", "<leader>lh", "<cmd> lua vim.lsp.buf.hover()<CR>", default_opts)
map("i", "<C-h>", "<cmd> lua vim.lsp.buf.signature_help()<CR>", default_opts) -- Show function signature map("i", "<C-h>", "<cmd> lua vim.lsp.buf.signature_help()<CR>", default_opts)
map("n", "<C-h>", "<cmd> lua vim.lsp.buf.signature_help()<CR>", default_opts) -- Show function signature map("n", "<C-h>", "<cmd> lua vim.lsp.buf.signature_help()<CR>", default_opts)
map("n", "<leader>ln", "<cmd> lua vim.lsp.buf.rename()<CR>", default_opts) -- Rename LSP symbol map("n", "<leader>ln", "<cmd> lua vim.lsp.buf.rename()<CR>", default_opts)
map("n", "<leader>lr", "<cmd> Telescope lsp_references<CR>", default_opts) -- Show all LSP references map("n", "<leader>lr", "<cmd> Telescope lsp_references<CR>", default_opts)
map("n", "<leader>ls", "<cmd> Telescope lsp_workspace_symbols<CR>", default_opts) -- Search for LSP symbols map("n", "<leader>ls", "<cmd> Telescope lsp_workspace_symbols<CR>", default_opts)
map("n", "<leader>lt", "<cmd> TodoTelescope<CR>", default_opts) -- Show all TODOs in a project map("n", "<leader>lt", "<cmd> TodoTelescope<CR>", default_opts)
map("n", "<leader>lp", "<cmd> call SVED_Sync()<CR>", default_opts) -- synctex map("n", "<leader>lp", "<cmd> call SVED_Sync()<CR>", default_opts)
wk.register({ wk.register({
["<leader>"] = { ["<leader>"] = {
l = { l = {
@@ -57,7 +57,7 @@ wk.register({
} }
}) })
-- git -- git(1)
map("n", "<leader>gb", "<cmd> Git blame<CR>", default_opts) map("n", "<leader>gb", "<cmd> Git blame<CR>", default_opts)
map("n", "<leader>gl", "<cmd> LazyGitFilter<CR>", default_opts) map("n", "<leader>gl", "<cmd> LazyGitFilter<CR>", default_opts)
map("n", "<leader>gf", "<cmd> LazyGitFilterCurrentFile<CR>", default_opts) map("n", "<leader>gf", "<cmd> LazyGitFilterCurrentFile<CR>", default_opts)
@@ -73,10 +73,10 @@ wk.register({
} }
}) })
-- Telescope + telescope-symbols -- telescope-symbols
map("n", "<leader>ie", "<cmd> lua require'telescope.builtin'.symbols{ sources = { 'emoji', 'gitmoji' } }<CR>", default_opts) -- Show emojis map("n", "<leader>ie", "<cmd> lua require'telescope.builtin'.symbols{ sources = { 'emoji', 'gitmoji' } }<CR>", default_opts)
map("n", "<leader>im", "<cmd> lua require'telescope.builtin'.symbols{ sources = { 'julia' } }<CR>", default_opts) -- Show math symbols map("n", "<leader>im", "<cmd> lua require'telescope.builtin'.symbols{ sources = { 'julia' } }<CR>", default_opts)
map("n", "<leader>in", "<cmd> lua require'telescope.builtin'.symbols{ sources = { 'nerd' } }<CR>", default_opts) -- Show nerd icons map("n", "<leader>in", "<cmd> lua require'telescope.builtin'.symbols{ sources = { 'nerd' } }<CR>", default_opts)
wk.register({ wk.register({
["<leader>"] = { ["<leader>"] = {
i = { i = {
@@ -116,3 +116,6 @@ cmp.setup({
}, },
}) })
-- nvim-tree
map("n", "<leader>tt", "<cmd> NvimTreeToggle<CR>", default_opts)
map("n", "<leader>tc", "<cmd> NvimTreeCollapse<CR>", default_opts)

View File

@@ -1 +0,0 @@
require('Comment').setup()

View File

@@ -1 +0,0 @@
require('gitsigns').setup()

View File

@@ -1 +0,0 @@
require('guess-indent').setup {}

View File

@@ -1,12 +1,11 @@
-- NOTE: -- NOTE: Required plugins are maintained here.
-- Define all plugins in this file,
-- but maintain config in <PLUGIN-NAME>-conf.lua
-- NOTE: -- NOTE: Plugin configuration: ${plugin}-conf.lua
-- Run `checkhealth` after first install
-- Mention all dependencies in 'requires', but create their own entry, -- NOTE: Use `checkhealth` after new installation
-- if they need configuration.
-- NOTE: Mention all dependencies in 'requires', but create their own entry,
-- if they need configuration.
local fn = vim.fn local fn = vim.fn
@@ -30,30 +29,26 @@ return require('packer').startup(function(use)
}) })
-- Icons -- Icons
-- Load here, because otherwise icons won't show correctly
use({ use({
"kyazdani42/nvim-web-devicons", 'kyazdani42/nvim-web-devicons',
config = function() require('plugins.nvim-web-devicons-conf') end, config = function() require 'nvim-web-devicons'.setup({ default = true }) end,
}) })
-- LuaLine -- LuaLine
use({ use({
"nvim-lualine/lualine.nvim", 'nvim-lualine/lualine.nvim',
requires = { requires = {
"kyazdani42/nvim-web-devicons", -- All icons in bar 'kyazdani42/nvim-web-devicons', -- All icons in bar
"arkav/lualine-lsp-progress", -- Show lsp loading progress
"SmiteshP/nvim-navic", -- Show breadcrumbs (loaded in lualine-conf)
"neovim/nvim-lspconfig", -- for nvim-navic (loaded later)
}, },
config = function() require('plugins.lualine-conf') end, config = function() require('plugins.lualine-conf') end,
}) })
-- Fuzzy Finder (Files etc) -- Fuzzy Finder (Files etc)
use({ use({
"nvim-telescope/telescope.nvim", 'nvim-telescope/telescope.nvim',
requires = { requires = {
"nvim-lua/plenary.nvim", -- General functions 'nvim-lua/plenary.nvim', -- General functions
"nvim-telescope/telescope-symbols.nvim", -- Search for icons 'nvim-telescope/telescope-symbols.nvim', -- Search for icons
}, },
config = function() require('plugins.telescope-conf') end, config = function() require('plugins.telescope-conf') end,
}) })
@@ -61,48 +56,51 @@ return require('packer').startup(function(use)
-- Auto Indentation -- Auto Indentation
use({ use({
'nmac427/guess-indent.nvim', 'nmac427/guess-indent.nvim',
config = function() require('plugins.guess-indent-conf') end, config = function() require('guess-indent').setup {} end,
}) })
-- Autopairs -- Autopairs
use({ use({
"windwp/nvim-autopairs", 'windwp/nvim-autopairs',
config = function() require('plugins.nvim-autopairs-conf') end, config = function() require('nvim-autopairs').setup({}) end,
}) })
-- Treesitter (Update with `:TSUpdate`) -- Treesitter
use({ use({
"nvim-treesitter/nvim-treesitter", 'nvim-treesitter/nvim-treesitter',
requires = {
'kyazdani42/nvim-web-devicons',
},
config = function() require('plugins.nvim-treesitter-conf') end, config = function() require('plugins.nvim-treesitter-conf') end,
}) })
-- LSP (install with `:LSPInstall`, inspect with `:LSPInfo`) -- LSP
use({ use({
"neovim/nvim-lspconfig", -- Easier to manage LSP servers 'neovim/nvim-lspconfig',
requires = { requires = {
"williamboman/nvim-lsp-installer", -- Easy to install LSP servers 'williamboman/nvim-lsp-installer',
"simrat39/rust-tools.nvim", -- Cooler LSP stuff for Rust 'simrat39/rust-tools.nvim',
}, },
config = function() require('plugins.nvim-lspconfig-conf') end, config = function() require('plugins.nvim-lspconfig-conf') end,
}) })
-- Snippets -- Suggestion window + snippets
use({ use({
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
requires = { requires = {
"L3MON4D3/LuaSnip", -- Snippet engine 'L3MON4D3/LuaSnip', -- Snippet engine
"hrsh7th/cmp-buffer", -- Source: buffer 'hrsh7th/cmp-buffer', -- Source: buffer
"hrsh7th/cmp-nvim-lsp", -- Source: LSP symbols 'hrsh7th/cmp-nvim-lsp', -- Source: LSP symbols
"hrsh7th/cmp-path", -- Source: path 'hrsh7th/cmp-path', -- Source: path
"rafamadriz/friendly-snippets", -- Source: JSON style snippets for LuaSnip 'rafamadriz/friendly-snippets', -- Source: JSON style snippets for LuaSnip
"saadparwaiz1/cmp_luasnip", -- Make LuaSnip work with cmp 'saadparwaiz1/cmp_luasnip', -- Make LuaSnip work with cmp
}, },
config = function() require('plugins.nvim-cmp-conf') end, config = function() require('plugins.nvim-cmp-conf') end,
}) })
-- which-key (Show key combos) -- which-key
use { use {
"folke/which-key.nvim", 'folke/which-key.nvim',
config = function() require('plugins.which-key-conf') end config = function() require('plugins.which-key-conf') end
} }
@@ -111,49 +109,52 @@ return require('packer').startup(function(use)
-- Easily comment out stuff -- Easily comment out stuff
use({ use({
"numToStr/Comment.nvim", 'numToStr/Comment.nvim',
config = function() require('plugins.Comment-conf') end, config = function() require('Comment').setup() end,
}) })
-- Highlight TODOs -- Highlight TODOs
use { use {
"folke/todo-comments.nvim", 'folke/todo-comments.nvim',
requires = "nvim-lua/plenary.nvim", requires = 'nvim-lua/plenary.nvim',
config = function() require('plugins.todo-comments-conf') end config = function() require('todo-comments').setup {} end,
} }
-- interactive git -- interactive git
use { use({ 'kdheepak/lazygit.nvim' })
'kdheepak/lazygit.nvim'
}
-- git cmd wrapper -- git command wrapper
use 'tpope/vim-fugitive' use({ 'tpope/vim-fugitive' })
-- git signs at left side (+ blame line) -- git signs at left side (+ blame line)
use { use({
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
config = function() require('plugins.gitsigns-conf') end config = function() require('gitsigns').setup() end,
} })
-- show color codes inline -- show color codes inline
use({ use({
"norcalli/nvim-colorizer.lua", 'norcalli/nvim-colorizer.lua',
config = function() require('plugins.nvim-colorizer-conf') end config = function() require 'colorizer'.setup() end,
}) })
-- fancy lsp loading animation -- fancy lsp loading animation
use({ use({
'j-hui/fidget.nvim', 'j-hui/fidget.nvim',
config = function() require "fidget".setup {} end, config = function() require 'fidget'.setup {} end,
}) })
-- latex synctex -- latex synctex (requires`pip install pygobject dbus-python pynvim`)
-- pip install pygobject dbus-python pynvim use({ 'peterbjorgensen/sved' })
use({ "peterbjorgensen/sved" })
-- d2 lang support -- d2-lang support (https://d2lang.com/tour/intro/)
use({"terrastruct/d2-vim"}) use({'terrastruct/d2-vim'})
-- tree sidebar
use({
'nvim-tree/nvim-tree.lua',
config = function() require('nvim-tree').setup() end,
})
-- Automatically set up your configuration after cloning packer.nvim -- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins -- Put this at the end after all plugins

View File

@@ -1,6 +1,3 @@
-- startup breadcrumbs
require 'nvim-navic'.setup({})
local function showTrailing() local function showTrailing()
local space = vim.fn.search([[\s\+$]], 'nwc') local space = vim.fn.search([[\s\+$]], 'nwc')
return space ~= 0 and "TW:" .. space or "" return space ~= 0 and "TW:" .. space or ""

View File

@@ -1 +0,0 @@
require('nvim-autopairs').setup({})

View File

@@ -1,3 +1,43 @@
lspkind = {
Namespace = "",
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
Table = "",
Object = "",
Tag = "",
Array = "[]",
Boolean = "",
Number = "",
Null = "",
String = "",
Calendar = "",
Watch = "",
Package = "",
}
local cmp = require 'cmp' local cmp = require 'cmp'
cmp.setup({ cmp.setup({
snippet = { snippet = {
@@ -14,8 +54,7 @@ cmp.setup({
formatting = { formatting = {
-- Show icons in cmp box -- Show icons in cmp box
format = function(_, vim_item) format = function(_, vim_item)
local icons = require("icons").lspkind vim_item.kind = string.format("%s %s", lspkind[vim_item.kind], vim_item.kind)
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
return vim_item return vim_item
end, end,
}, },

View File

@@ -1 +0,0 @@
require 'colorizer'.setup()

View File

@@ -20,10 +20,9 @@ require("nvim-lsp-installer").setup({
}) })
local lsp = require('lspconfig') local lsp = require('lspconfig')
local navic = require('nvim-navic') -- breadcrumbs
-- own custom attach, gets called in every client
function my_attach (client, bufnr) function my_attach (client, bufnr)
navic.attach(client, bufnr) -- breadcrumbs
end end
-- Normal LSPs -- Normal LSPs

View File

@@ -1,5 +1,5 @@
require('nvim-treesitter.configs').setup({ require('nvim-treesitter.configs').setup({
ensure_installed = { -- can also be manually installed with :TSInstall ensure_installed = {
"bash", "bash",
"c", "c",
"haskell", "haskell",

View File

@@ -1,3 +0,0 @@
require 'nvim-web-devicons'.setup({
default = true
})

View File

@@ -1 +0,0 @@
require("todo-comments").setup {}