[NeoVim] LaTeX + Snippets

This commit is contained in:
2022-07-25 19:08:00 +02:00
parent d38ce6a1c7
commit 43ba9953aa
3 changed files with 29 additions and 7 deletions

View File

@@ -237,6 +237,10 @@ vim.keymap.set("n", "r", "<cmd>DiffviewOpen<CR>")
vim.keymap.set("n", "R", "<cmd>DiffviewFileHistory %<CR>") vim.keymap.set("n", "R", "<cmd>DiffviewFileHistory %<CR>")
vim.g.vimtex_view_method = 'zathura'
vim.g.maplocalleader = ','
vim.o.clipboard = 'unnamedplus' vim.o.clipboard = 'unnamedplus'
vim.o.expandtab = true vim.o.expandtab = true
vim.o.fileencoding = 'utf-8' vim.o.fileencoding = 'utf-8'

View File

@@ -1,4 +1,4 @@
local servers = { 'pyright', 'sumneko_lua', 'eslint', 'tsserver' } local servers = { 'pyright', 'sumneko_lua', 'eslint', 'tsserver', 'ltex' }
-- Mappings. -- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions -- See `:help vim.diagnostic.*` for documentation on any of the below functions
@@ -11,9 +11,6 @@ vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys -- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings. -- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr } local bufopts = { noremap=true, silent=true, buffer=bufnr }
@@ -52,8 +49,10 @@ end
-- luasnip setup -- luasnip setup
local luasnip = require 'luasnip' local luasnip = require 'luasnip'
require('luasnip.loaders.from_vscode').lazy_load()
-- nvim-cmp setup -- nvim-cmp setup
local lspkind = require('lspkind')
local cmp = require 'cmp' local cmp = require 'cmp'
cmp.setup { cmp.setup {
snippet = { snippet = {
@@ -89,7 +88,18 @@ cmp.setup {
end, { 'i', 's' }), end, { 'i', 's' }),
}), }),
sources = { sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' }, { name = 'luasnip' },
{ name = 'nvim_lsp' },
{ name = 'omni' }
}, },
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text",
menu = ({
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
omni = "[Omni]"
})
})
}
} }

View File

@@ -48,9 +48,17 @@ return require('packer').startup(function()
use { use {
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
'hrsh7th/cmp-omni',
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
'saadparwaiz1/cmp_luasnip', 'onsails/lspkind.nvim'
'L3MON4D3/LuaSnip'
} }
use {
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
'rafamadriz/friendly-snippets'
}
use 'lervag/vimtex'
end) end)