ft: add rest of nvim config
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
-- Make sure to update packer with `:PackerInstall` and `:PackerSync`
|
||||
-- Treesitter with `:TSUpdate`
|
||||
-- LSP with `:LSPInstall`, log with `:LSPInfo`
|
||||
|
||||
require 'plugins' -- Load plugins
|
||||
require 'settings' -- General settings
|
||||
require 'mappings' -- Keyboard mappings
|
||||
|
||||
-- Plugin specific
|
||||
require 'lsp'
|
||||
require 'lsp' -- Everything related to LSP
|
||||
|
||||
@@ -18,12 +18,31 @@ require("nvim-lsp-installer").setup({
|
||||
})
|
||||
|
||||
local lsp = require('lspconfig')
|
||||
local navic = require('nvim-navic') -- breadcrumbs
|
||||
|
||||
-- Normal LSPs
|
||||
lsp.pylsp.setup({})
|
||||
lsp.texlab.setup({})
|
||||
lsp.sumneko_lua.setup({})
|
||||
lsp.hls.setup({})
|
||||
-- Install with `:LSPInstall`
|
||||
local servers = { "pylsp", "sumneko_lua", "hls" }
|
||||
for _,i in ipairs(servers) do
|
||||
lsp[i].setup({
|
||||
on_attach = function(client, bufnr)
|
||||
navic.attach(client, bufnr) -- breadcrumbs
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
-- LaTeX (build with `:TexlabBuild`)
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/texlab.lua
|
||||
lsp.texlab.setup({
|
||||
settings = {
|
||||
texlab = {
|
||||
build = {
|
||||
args = { '-pdf', '-interaction=nonstopmode', '-synctex=1', '-shell-escape','%f' },
|
||||
onSave = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
-- Rust (use rust-tools to setup lsp, because it has more features)
|
||||
local opts = {
|
||||
@@ -37,6 +56,9 @@ local opts = {
|
||||
},
|
||||
},
|
||||
server = {
|
||||
on_attach = function(client, bufnr)
|
||||
navic.attach(client, bufnr) -- breadcrumbs
|
||||
end,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
checkOnSave = {
|
||||
|
||||
@@ -3,8 +3,10 @@ local default_opts = { noremap = true, silent = true }
|
||||
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
map("n", "<C-_>", "<cmd> noh<CR>", default_opts)
|
||||
|
||||
-- Telescope
|
||||
local telescope = require'telescope'
|
||||
local telescope = require 'telescope'
|
||||
local actions = require "telescope.actions"
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
@@ -20,26 +22,31 @@ telescope.setup({
|
||||
}
|
||||
}
|
||||
})
|
||||
map("n", "<C-f>", "<cmd> Telescope find_files<CR>", default_opts)
|
||||
map("n", "<C-g>", "<cmd> Telescope live_grep<CR>", default_opts)
|
||||
map("n", "<C-k>", "<cmd> Telescope keymaps<CR>", default_opts)
|
||||
map("n", "<C-f>", "<cmd> Telescope find_files<CR>", default_opts) -- Show files
|
||||
map("n", "<C-g>", "<cmd> Telescope live_grep<CR>", default_opts) -- Grep through current directory
|
||||
map("n", "<C-k>", "<cmd> Telescope keymaps<CR>", default_opts) -- Show all keys
|
||||
|
||||
-- Telescope + LSP
|
||||
map("n", "<leader>ls", "<cmd> Telescope lsp_workspace_symbols<CR>", default_opts)
|
||||
map("n", "<leader>ld", "<cmd> Telescope lsp_definitions<CR>", default_opts)
|
||||
map("n", "<leader>lr", "<cmd> Telescope lsp_references<CR>", default_opts)
|
||||
map("n", "<leader>le", "<cmd> TroubleToggle<CR>", default_opts)
|
||||
map("n", "<leader>la", "<cmd> lua vim.lsp.buf.code_action<CR>", default_opts)
|
||||
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>le", "<cmd> TroubleToggle<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>lh", "<cmd> lua vim.lsp.buf.hover()<CR>", default_opts) -- Show info of symbol (double tap to enter)
|
||||
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
|
||||
|
||||
-- Telescope + git(1)
|
||||
map("n", "<leader>gs", "<cmd> Telescope git_status<CR>", default_opts)
|
||||
|
||||
-- cmp
|
||||
local cmp = require'cmp'
|
||||
local cmp = require 'cmp'
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-j>"] = cmp.mapping.select_next_item(),
|
||||
},
|
||||
}
|
||||
)
|
||||
["<C-l>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
|
||||
-- TODO: null-ls (Formatting)
|
||||
-- TODO: TODO Marking
|
||||
-- TODO: Latex stuff (synctex, bibtex)
|
||||
-- TODO: add own snippets (for latex {notes, presentation, wfig, srcd, srci})
|
||||
|
||||
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
|
||||
packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
|
||||
packer_bootstrap = fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim',
|
||||
install_path })
|
||||
end
|
||||
|
||||
return require('packer').startup(function(use)
|
||||
@@ -25,12 +24,55 @@ return require('packer').startup(function(use)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Breadcrumbs (will be loaded into LuaLine)
|
||||
use {
|
||||
"SmiteshP/nvim-navic",
|
||||
requires = "neovim/nvim-lspconfig",
|
||||
config = function()
|
||||
require 'nvim-navic'.setup({})
|
||||
end,
|
||||
}
|
||||
|
||||
-- LuaLine
|
||||
use({
|
||||
"nvim-lualine/lualine.nvim",
|
||||
requires = { "kyazdani42/nvim-web-devicons", opt = true },
|
||||
requires = {
|
||||
{ "kyazdani42/nvim-web-devicons", opt = true, }, -- Icons
|
||||
"arkav/lualine-lsp-progress", -- Show lsp loading progress
|
||||
"SmiteshP/nvim-navic", -- Show breadcrumbs
|
||||
},
|
||||
config = function()
|
||||
require('lualine').setup({ options = { theme = 'everforest' } })
|
||||
require('lualine').setup({
|
||||
options = {
|
||||
theme = 'everforest'
|
||||
},
|
||||
sections = {
|
||||
lualine_b = {
|
||||
'branch',
|
||||
'diff',
|
||||
{
|
||||
'diagnostics',
|
||||
-- fake colors from Trouble
|
||||
diagnostics_color = {
|
||||
warn = { fg = '#dfa000'},
|
||||
info = { fg = "#4a94c5"},
|
||||
hint = { fg = "35a77c"}
|
||||
},
|
||||
}
|
||||
|
||||
},
|
||||
lualine_c = { 'filename', require('nvim-navic').get_location },
|
||||
lualine_x = { 'lsp_progress', 'encoding', 'fileformat', 'filetype' },
|
||||
lualine_z = {
|
||||
'location',
|
||||
function()
|
||||
-- Show trailing whitespace
|
||||
local space = vim.fn.search([[\s\+$]], 'nwc')
|
||||
return space ~= 0 and "TW:"..space or ""
|
||||
end
|
||||
}
|
||||
}
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -54,7 +96,7 @@ return require('packer').startup(function(use)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Treesitter
|
||||
-- Treesitter (Update with `:TSUpdate`)
|
||||
use({
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
config = function()
|
||||
@@ -69,10 +111,12 @@ return require('packer').startup(function(use)
|
||||
end,
|
||||
})
|
||||
|
||||
-- LSP
|
||||
use("neovim/nvim-lspconfig")
|
||||
use("williamboman/nvim-lsp-installer")
|
||||
use("simrat39/rust-tools.nvim") -- Cooler LSP stuff for Rust
|
||||
-- LSP (install with `:LSPInstall`, inspect with `:LSPInfo`)
|
||||
use("neovim/nvim-lspconfig") -- Easy to manage LSP servers (attach etc)
|
||||
use("williamboman/nvim-lsp-installer") -- Easy to install LSP servers
|
||||
use("simrat39/rust-tools.nvim") -- Cooler LSP stuff for Rust
|
||||
|
||||
-- Show error neatly in a minibuffer
|
||||
use {
|
||||
"folke/trouble.nvim",
|
||||
requires = {
|
||||
@@ -80,36 +124,37 @@ return require('packer').startup(function(use)
|
||||
"folke/lsp-colors.nvim",
|
||||
},
|
||||
config = function() require("trouble").setup {} end,
|
||||
}
|
||||
}
|
||||
|
||||
-- Snippets
|
||||
-- TODO: texlab doenst show snippets? (happy snippets)
|
||||
-- TODO: add friendly snippets
|
||||
-- https://github.com/deniserdogan/dotfiles/blob/master/lua/dannzi.lua
|
||||
use({
|
||||
'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-path",
|
||||
"rafamadriz/friendly-snippets",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
config = function()
|
||||
local cmp = require'cmp'
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
-- require("luasnip.loaders.from_vscode").lazy_load({ paths = { "~/.config/nvim/snippets" } })
|
||||
local cmp = require 'cmp'
|
||||
cmp.setup({
|
||||
-- snippet = {
|
||||
-- expand = function(args)
|
||||
-- require("luasnip").lsp_expand(args.body)
|
||||
-- end,
|
||||
-- },
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'path' },
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
},
|
||||
formatting = {
|
||||
-- Show icons in cmp box
|
||||
format = function(_, vim_item)
|
||||
local icons = require("icons").lspkind
|
||||
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
|
||||
@@ -124,7 +169,27 @@ return require('packer').startup(function(use)
|
||||
use {
|
||||
"folke/which-key.nvim",
|
||||
config = function()
|
||||
require("which-key").setup { }
|
||||
require("which-key").setup {}
|
||||
end
|
||||
}
|
||||
|
||||
-- Align with `:Align <regex>`
|
||||
use 'RRethy/nvim-align'
|
||||
|
||||
-- Easily comment out stuff (gc, gb)
|
||||
use({
|
||||
"numToStr/Comment.nvim",
|
||||
config = function()
|
||||
require('Comment').setup({})
|
||||
end,
|
||||
})
|
||||
|
||||
-- Highlight TODOs
|
||||
use {
|
||||
"folke/todo-comments.nvim",
|
||||
requires = "nvim-lua/plenary.nvim",
|
||||
config = function()
|
||||
require("todo-comments").setup {}
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
local opt = vim.opt
|
||||
local opt = vim.opt
|
||||
|
||||
opt.colorcolumn = "80"
|
||||
opt.cursorline = true
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
opt.scrolloff = 12
|
||||
opt.signcolumn = "yes"
|
||||
opt.swapfile = false
|
||||
opt.colorcolumn = "80" -- Colored column at 80c
|
||||
opt.cursorline = true -- Highlight entire current row
|
||||
opt.number = true -- Show line numbers
|
||||
opt.relativenumber = true -- Show relative line numbers from cursor
|
||||
opt.scrolloff = 12 -- Minimum lines at top and bottom
|
||||
opt.signcolumn = "yes" -- Show icons column at on the left side
|
||||
opt.swapfile = false -- Do not create a swapfile
|
||||
opt.smartindent = true -- Autoindent new lines
|
||||
opt.showmode = false -- Disable status on most bottom row
|
||||
opt.clipboard = "unnamed" -- Copy & Paste with system clipboard
|
||||
opt.list = true -- Show trailing whitespaces
|
||||
|
||||
opt.smartindent = true -- autoindent new lines
|
||||
vim.opt.undofile = true -- Save undo history
|
||||
vim.o.mouse = 'a' -- Enable mouse
|
||||
|
||||
Reference in New Issue
Block a user