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 'plugins' -- Load plugins
|
||||||
require 'settings' -- General settings
|
require 'settings' -- General settings
|
||||||
require 'mappings' -- Keyboard mappings
|
require 'mappings' -- Keyboard mappings
|
||||||
|
require 'lsp' -- Everything related to LSP
|
||||||
-- Plugin specific
|
|
||||||
require 'lsp'
|
|
||||||
|
|||||||
@@ -18,12 +18,31 @@ require("nvim-lsp-installer").setup({
|
|||||||
})
|
})
|
||||||
|
|
||||||
local lsp = require('lspconfig')
|
local lsp = require('lspconfig')
|
||||||
|
local navic = require('nvim-navic') -- breadcrumbs
|
||||||
|
|
||||||
-- Normal LSPs
|
-- Normal LSPs
|
||||||
lsp.pylsp.setup({})
|
-- Install with `:LSPInstall`
|
||||||
lsp.texlab.setup({})
|
local servers = { "pylsp", "sumneko_lua", "hls" }
|
||||||
lsp.sumneko_lua.setup({})
|
for _,i in ipairs(servers) do
|
||||||
lsp.hls.setup({})
|
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)
|
-- Rust (use rust-tools to setup lsp, because it has more features)
|
||||||
local opts = {
|
local opts = {
|
||||||
@@ -37,6 +56,9 @@ local opts = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
server = {
|
server = {
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
navic.attach(client, bufnr) -- breadcrumbs
|
||||||
|
end,
|
||||||
settings = {
|
settings = {
|
||||||
["rust-analyzer"] = {
|
["rust-analyzer"] = {
|
||||||
checkOnSave = {
|
checkOnSave = {
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ local default_opts = { noremap = true, silent = true }
|
|||||||
|
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
|
|
||||||
|
map("n", "<C-_>", "<cmd> noh<CR>", default_opts)
|
||||||
|
|
||||||
-- Telescope
|
-- Telescope
|
||||||
local telescope = require'telescope'
|
local telescope = require 'telescope'
|
||||||
local actions = require "telescope.actions"
|
local actions = require "telescope.actions"
|
||||||
telescope.setup({
|
telescope.setup({
|
||||||
defaults = {
|
defaults = {
|
||||||
@@ -20,26 +22,31 @@ telescope.setup({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
map("n", "<C-f>", "<cmd> Telescope find_files<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)
|
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)
|
map("n", "<C-k>", "<cmd> Telescope keymaps<CR>", default_opts) -- Show all keys
|
||||||
|
|
||||||
-- Telescope + LSP
|
-- Telescope + LSP
|
||||||
map("n", "<leader>ls", "<cmd> Telescope lsp_workspace_symbols<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)
|
map("n", "<leader>ld", "<cmd> Telescope lsp_definitions<CR>", default_opts) -- Show all LSP definitions (or jump if only 1)
|
||||||
map("n", "<leader>lr", "<cmd> Telescope lsp_references<CR>", default_opts)
|
map("n", "<leader>le", "<cmd> TroubleToggle<CR>", default_opts) -- Show errors and warnings
|
||||||
map("n", "<leader>le", "<cmd> TroubleToggle<CR>", default_opts)
|
map("n", "<leader>lf", "<cmd> lua vim.lsp.buf.formatting()<CR>", default_opts) -- Format buffer with LSP
|
||||||
map("n", "<leader>la", "<cmd> lua vim.lsp.buf.code_action<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>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)
|
-- Telescope + git(1)
|
||||||
map("n", "<leader>gs", "<cmd> Telescope git_status<CR>", default_opts)
|
map("n", "<leader>gs", "<cmd> Telescope git_status<CR>", default_opts)
|
||||||
|
|
||||||
-- cmp
|
-- cmp
|
||||||
local cmp = require'cmp'
|
local cmp = require 'cmp'
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
mapping = {
|
mapping = {
|
||||||
["<C-k>"] = cmp.mapping.select_prev_item(),
|
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||||
["<C-j>"] = cmp.mapping.select_next_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]]
|
vim.cmd [[packadd packer.nvim]]
|
||||||
|
|
||||||
-- TODO: null-ls (Formatting)
|
-- TODO: add own snippets (for latex {notes, presentation, wfig, srcd, srci})
|
||||||
-- TODO: TODO Marking
|
|
||||||
-- TODO: Latex stuff (synctex, bibtex)
|
|
||||||
|
|
||||||
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
|
||||||
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
|
end
|
||||||
|
|
||||||
return require('packer').startup(function(use)
|
return require('packer').startup(function(use)
|
||||||
@@ -25,12 +24,55 @@ return require('packer').startup(function(use)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Breadcrumbs (will be loaded into LuaLine)
|
||||||
|
use {
|
||||||
|
"SmiteshP/nvim-navic",
|
||||||
|
requires = "neovim/nvim-lspconfig",
|
||||||
|
config = function()
|
||||||
|
require 'nvim-navic'.setup({})
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
-- LuaLine
|
-- LuaLine
|
||||||
use({
|
use({
|
||||||
"nvim-lualine/lualine.nvim",
|
"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()
|
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,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -54,7 +96,7 @@ return require('packer').startup(function(use)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Treesitter
|
-- Treesitter (Update with `:TSUpdate`)
|
||||||
use({
|
use({
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
config = function()
|
config = function()
|
||||||
@@ -69,10 +111,12 @@ return require('packer').startup(function(use)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- LSP
|
-- LSP (install with `:LSPInstall`, inspect with `:LSPInfo`)
|
||||||
use("neovim/nvim-lspconfig")
|
use("neovim/nvim-lspconfig") -- Easy to manage LSP servers (attach etc)
|
||||||
use("williamboman/nvim-lsp-installer")
|
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 {
|
use {
|
||||||
"folke/trouble.nvim",
|
"folke/trouble.nvim",
|
||||||
requires = {
|
requires = {
|
||||||
@@ -80,36 +124,37 @@ return require('packer').startup(function(use)
|
|||||||
"folke/lsp-colors.nvim",
|
"folke/lsp-colors.nvim",
|
||||||
},
|
},
|
||||||
config = function() require("trouble").setup {} end,
|
config = function() require("trouble").setup {} end,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Snippets
|
-- Snippets
|
||||||
-- TODO: texlab doenst show snippets? (happy snippets)
|
|
||||||
-- TODO: add friendly snippets
|
|
||||||
-- https://github.com/deniserdogan/dotfiles/blob/master/lua/dannzi.lua
|
|
||||||
use({
|
use({
|
||||||
'hrsh7th/nvim-cmp',
|
'hrsh7th/nvim-cmp',
|
||||||
requires = {
|
requires = {
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
|
||||||
"saadparwaiz1/cmp_luasnip",
|
|
||||||
"L3MON4D3/LuaSnip",
|
"L3MON4D3/LuaSnip",
|
||||||
"hrsh7th/cmp-path",
|
|
||||||
"hrsh7th/cmp-buffer",
|
"hrsh7th/cmp-buffer",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
},
|
},
|
||||||
config = function()
|
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({
|
cmp.setup({
|
||||||
-- snippet = {
|
snippet = {
|
||||||
-- expand = function(args)
|
expand = function(args)
|
||||||
-- require("luasnip").lsp_expand(args.body)
|
require("luasnip").lsp_expand(args.body)
|
||||||
-- end,
|
end,
|
||||||
-- },
|
},
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
{ name = 'path' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
|
{ name = 'path' },
|
||||||
},
|
},
|
||||||
formatting = {
|
formatting = {
|
||||||
|
-- Show icons in cmp box
|
||||||
format = function(_, vim_item)
|
format = function(_, vim_item)
|
||||||
local icons = require("icons").lspkind
|
local icons = require("icons").lspkind
|
||||||
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
|
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 {
|
use {
|
||||||
"folke/which-key.nvim",
|
"folke/which-key.nvim",
|
||||||
config = function()
|
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
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
local opt = vim.opt
|
local opt = vim.opt
|
||||||
|
|
||||||
opt.colorcolumn = "80"
|
opt.colorcolumn = "80" -- Colored column at 80c
|
||||||
opt.cursorline = true
|
opt.cursorline = true -- Highlight entire current row
|
||||||
opt.number = true
|
opt.number = true -- Show line numbers
|
||||||
opt.relativenumber = true
|
opt.relativenumber = true -- Show relative line numbers from cursor
|
||||||
opt.scrolloff = 12
|
opt.scrolloff = 12 -- Minimum lines at top and bottom
|
||||||
opt.signcolumn = "yes"
|
opt.signcolumn = "yes" -- Show icons column at on the left side
|
||||||
opt.swapfile = false
|
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