nvim: add various keybinds and neogit
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
local map = vim.api.nvim_set_keymap
|
local map = vim.api.nvim_set_keymap
|
||||||
|
local wk = require 'which-key'
|
||||||
local default_opts = { noremap = true, silent = true }
|
local default_opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
@@ -29,14 +30,52 @@ map("n", "<C-k>", "<cmd> Telescope keymaps<CR>", default_opts) -- Show all ke
|
|||||||
-- Telescope + LSP
|
-- Telescope + 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) -- Apply LSP code action
|
||||||
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) -- Show all LSP definitions (or jump if only 1)
|
||||||
map("n", "<leader>le", "<cmd> TroubleToggle<CR>", default_opts) -- Show errors and warnings
|
map("n", "<leader>le", "<cmd> Telescope diagnostics<CR>", default_opts) -- Show errors and warnings
|
||||||
map("n", "<leader>lf", "<cmd> lua vim.lsp.buf.formatting()<CR>", default_opts) -- Format buffer with LSP
|
map("n", "<leader>lf", "<cmd> lua vim.lsp.buf.formatting()<CR>", default_opts) -- Format buffer with LSP
|
||||||
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) -- Show info of symbol (double tap to enter)
|
||||||
|
map("n", "<leader>ln", "<cmd> lua vim.lsp.buf.rename()<CR>", default_opts) -- Rename LSP symbol
|
||||||
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) -- Show all LSP references
|
||||||
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) -- Search for LSP symbols
|
||||||
|
map("n", "<leader>lt", "<cmd> TodoTelescope<CR>", default_opts) -- Search for LSP symbols
|
||||||
|
wk.register({
|
||||||
|
["<leader>"] = {
|
||||||
|
l = {
|
||||||
|
a = { "Actions" },
|
||||||
|
d = { "Definitions" },
|
||||||
|
e = { "Errors" },
|
||||||
|
f = { "Format buffer" },
|
||||||
|
h = { "Hover information" },
|
||||||
|
n = { "(Re)Name symbol" },
|
||||||
|
r = { "References" },
|
||||||
|
s = { "Symbols" },
|
||||||
|
t = { "TODOs" },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
-- Telescope + git(1)
|
-- git
|
||||||
map("n", "<leader>gs", "<cmd> Telescope git_status<CR>", default_opts)
|
map("n", "<leader>gs", "<cmd> Neogit<CR>", default_opts)
|
||||||
|
wk.register({
|
||||||
|
["<leader>"] = {
|
||||||
|
g = {
|
||||||
|
s = { "Status" },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Telescope + telescope-symbols
|
||||||
|
map("n", "<leader>ie", "<cmd> lua require'telescope.builtin'.symbols{ sources = { 'emoji', 'gitmoji' } }<CR>", default_opts) -- Show emojis
|
||||||
|
map("n", "<leader>im", "<cmd> lua require'telescope.builtin'.symbols{ sources = { 'julia' } }<CR>", default_opts) -- Show math symbols
|
||||||
|
map("n", "<leader>in", "<cmd> lua require'telescope.builtin'.symbols{ sources = { 'nerd' } }<CR>", default_opts) -- Show nerd icons
|
||||||
|
wk.register({
|
||||||
|
["<leader>"] = {
|
||||||
|
i = {
|
||||||
|
e = { "Emoji" },
|
||||||
|
m = { "Math symbol" },
|
||||||
|
n = { "Nerd Font" },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
-- cmp
|
-- cmp
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
vim.cmd [[packadd packer.nvim]]
|
vim.cmd [[packadd packer.nvim]]
|
||||||
|
|
||||||
-- TODO: add own snippets (for latex {notes, presentation, wfig, srcd, srci})
|
|
||||||
|
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
||||||
if fn.empty(fn.glob(install_path)) > 0 then
|
if fn.empty(fn.glob(install_path)) > 0 then
|
||||||
@@ -33,13 +31,23 @@ return require('packer').startup(function(use)
|
|||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Icons
|
||||||
|
use({
|
||||||
|
"kyazdani42/nvim-web-devicons",
|
||||||
|
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", opt = true, }, -- Icons
|
"kyazdani42/nvim-web-devicons",
|
||||||
"arkav/lualine-lsp-progress", -- Show lsp loading progress
|
"arkav/lualine-lsp-progress", -- Show lsp loading progress
|
||||||
"SmiteshP/nvim-navic", -- Show breadcrumbs
|
"SmiteshP/nvim-navic", -- Show breadcrumbs
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require('lualine').setup({
|
require('lualine').setup({
|
||||||
@@ -52,11 +60,10 @@ return require('packer').startup(function(use)
|
|||||||
'diff',
|
'diff',
|
||||||
{
|
{
|
||||||
'diagnostics',
|
'diagnostics',
|
||||||
-- fake colors from Trouble
|
|
||||||
diagnostics_color = {
|
diagnostics_color = {
|
||||||
warn = { fg = '#dfa000'},
|
warn = { fg = "orange" },
|
||||||
info = { fg = "#4a94c5"},
|
info = { fg = "#479bc7" },
|
||||||
hint = { fg = "35a77c"}
|
hint = { fg = "darkcyan" }
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +75,7 @@ return require('packer').startup(function(use)
|
|||||||
function()
|
function()
|
||||||
-- Show trailing whitespace
|
-- Show trailing whitespace
|
||||||
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 ""
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +86,26 @@ return require('packer').startup(function(use)
|
|||||||
-- Fuzzy Finder (Files etc)
|
-- Fuzzy Finder (Files etc)
|
||||||
use({
|
use({
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
requires = { { "nvim-lua/plenary.nvim" } },
|
requires = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
"nvim-telescope/telescope-symbols.nvim", -- Search for icons
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('telescope').setup({
|
||||||
|
defaults = {
|
||||||
|
prompt_prefix = " ",
|
||||||
|
selection_caret = " ",
|
||||||
|
entry_prefix = " ",
|
||||||
|
sorting_strategy = "ascending",
|
||||||
|
layout_strategy = "horizontal",
|
||||||
|
layout_config = {
|
||||||
|
horizontal = {
|
||||||
|
prompt_position = "top",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Auto Indentation
|
-- Auto Indentation
|
||||||
@@ -101,7 +127,16 @@ return require('packer').startup(function(use)
|
|||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
config = function()
|
config = function()
|
||||||
require('nvim-treesitter.configs').setup({
|
require('nvim-treesitter.configs').setup({
|
||||||
ensure_installed = { "c", "rust", "lua", "python", "haskell" },
|
ensure_installed = {
|
||||||
|
"bash",
|
||||||
|
"c",
|
||||||
|
"haskell",
|
||||||
|
"json",
|
||||||
|
"latex",
|
||||||
|
"lua",
|
||||||
|
"python",
|
||||||
|
"rust",
|
||||||
|
},
|
||||||
auto_intall = true,
|
auto_intall = true,
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = true,
|
||||||
@@ -112,21 +147,13 @@ return require('packer').startup(function(use)
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- LSP (install with `:LSPInstall`, inspect with `:LSPInfo`)
|
-- LSP (install with `:LSPInstall`, inspect with `:LSPInfo`)
|
||||||
use("neovim/nvim-lspconfig") -- Easy to manage LSP servers (attach etc)
|
use("neovim/nvim-lspconfig") -- Easy to manage LSP servers (attach etc)
|
||||||
use("williamboman/nvim-lsp-installer") -- Easy to install LSP servers
|
use("williamboman/nvim-lsp-installer") -- Easy to install LSP servers
|
||||||
use("simrat39/rust-tools.nvim") -- Cooler LSP stuff for Rust
|
use("simrat39/rust-tools.nvim") -- Cooler LSP stuff for Rust
|
||||||
|
|
||||||
-- Show error neatly in a minibuffer
|
|
||||||
use {
|
|
||||||
"folke/trouble.nvim",
|
|
||||||
requires = {
|
|
||||||
"kyazdani42/nvim-web-devicons",
|
|
||||||
"folke/lsp-colors.nvim",
|
|
||||||
},
|
|
||||||
config = function() require("trouble").setup {} end,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Snippets
|
-- Snippets
|
||||||
|
-- TODO: max candidates
|
||||||
|
-- TODO: time trigger activation
|
||||||
use({
|
use({
|
||||||
'hrsh7th/nvim-cmp',
|
'hrsh7th/nvim-cmp',
|
||||||
requires = {
|
requires = {
|
||||||
@@ -138,8 +165,6 @@ return require('packer').startup(function(use)
|
|||||||
"saadparwaiz1/cmp_luasnip",
|
"saadparwaiz1/cmp_luasnip",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require('luasnip.loaders.from_vscode').lazy_load()
|
|
||||||
-- require("luasnip.loaders.from_vscode").lazy_load({ paths = { "~/.config/nvim/snippets" } })
|
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
@@ -162,6 +187,15 @@ return require('packer').startup(function(use)
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
-- Load in friendly-snippets
|
||||||
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
|
-- TODO: Add own snippets
|
||||||
|
--[[ require("luasnip.loaders.from_vscode").lazy_load({
|
||||||
|
paths = {
|
||||||
|
"~/.config/nvim/snippets",
|
||||||
|
"/home/marc/.local/share/nvim/site/pack/packer/start/friendly-snippets"
|
||||||
|
}
|
||||||
|
}) ]]
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -193,6 +227,21 @@ return require('packer').startup(function(use)
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- git client
|
||||||
|
use {
|
||||||
|
'TimUntersberger/neogit',
|
||||||
|
requires = 'nvim-lua/plenary.nvim',
|
||||||
|
config = function()
|
||||||
|
local neogit = require('neogit')
|
||||||
|
neogit.setup {
|
||||||
|
signs = {
|
||||||
|
section = { "", "" },
|
||||||
|
item = { "", "" },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
||||||
if packer_bootstrap then
|
if packer_bootstrap then
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local opt = vim.opt
|
local opt = vim.opt
|
||||||
|
|
||||||
opt.colorcolumn = "80" -- Colored column at 80c
|
opt.colorcolumn = "80" -- Colored column at 80c
|
||||||
opt.cursorline = true -- Highlight entire current row
|
opt.cursorline = true -- Highlight entire current row
|
||||||
|
|||||||
Reference in New Issue
Block a user