Fixed LSP support for Lean and Latex

main
zoomiti 4 years ago
parent f266b2dab0
commit cdb1a37687

@ -1,23 +0,0 @@
snippet \and "and" A
endsnippet
snippet \or "and" A
endsnippet
snippet \neg "not" A
¬
endsnippet
snippet \to "\to ->" A
endsnippet
snippet \iff "\iff <->" A
endsnippet
snippet \forall "forrall" A
endsnippet

@ -5,6 +5,7 @@ if empty(glob(data_dir . '/autoload/plug.vim'))
endif endif
call plug#begin() call plug#begin()
" CSS-Color
Plug 'ap/vim-css-color' Plug 'ap/vim-css-color'
"Surround "Surround
@ -16,17 +17,19 @@ Plug 'lervag/vimtex'
" For snippets " For snippets
Plug 'SirVer/ultisnips' Plug 'SirVer/ultisnips'
"LEAN REQUIRES NVIM
if has("nvim") if has("nvim")
Plug 'Julian/lean.nvim' " LSP
Plug 'neovim/nvim-lspconfig' Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/plenary.nvim' Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/nvim-cmp' " For LSP completion
Plug 'hrsh7th/nvim-compe' " For LSP completion "Lean requires nvim
Plug 'Julian/lean.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'andrewradev/switch.vim' " For Lean switch support Plug 'andrewradev/switch.vim' " For Lean switch support
end end
call plug#end()
call plug#end()
" Conceal options " Conceal options
hi clear Conceal hi clear Conceal
@ -40,29 +43,26 @@ let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
set encoding=utf-8 set encoding=utf-8
set completeopt=menu,menuone,noselect
" Tab AutoComplete " Tab AutoComplete
function! InsertTabWrapper() function! InsertTabWrapper()
let col = col('.') - 1 let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k' if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>" return "\<tab>"
else else
return "\<c-p>" return "\<c-p>"
endif endif
endfunction endfunction
inoremap <expr> <tab> InsertTabWrapper() inoremap <expr> <tab> InsertTabWrapper()
inoremap <s-tab> <c-n> inoremap <s-tab> <c-n>
" Make " Make
set makeprg=make\ --silent\ 2>&1\ \\\|\ grep\ -E\ \"^([^:\\S]+):\\S+:.+\" set makeprg=make\ --silent\ 2>&1\ \\\|\ grep\ -E\ \"^([^:\\S]+):\\S+:.+\"
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on syntax on
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when " Uncomment the following to have Vim jump to the last position when
" reopening a file " reopening a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
@ -123,18 +123,47 @@ end
" Source a global configuration file if available " Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local") if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local source /etc/vim/vimrc.local
endif endif
" LSP Setup " LSP Setup
if has("nvim") if has("nvim")
lua <<EOF lua <<EOF
-- If you don't already have a preferred neovim LSP setup, you may want
-- to reference the nvim-lspconfig documentation, which can be found at: -- Setup nvim-cmp.
-- https://github.com/neovim/nvim-lspconfig#keybindings-and-completion local cmp = require'cmp'
-- For completeness (of showing this plugin's settings), we show
-- a barebones LSP attach handler (which will give you Lean LSP cmp.setup({
-- functionality in attached buffers) here: snippet = {
expand = function(args)
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
-- require'snippy'.expand_snippet(args.body) -- For `snippy` users.
end,
},
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
-- { name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users.
{ name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
})
})
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
require('lspconfig')['texlab'].setup { capabilities = capabilities }
local function on_attach(client, bufnr) local function on_attach(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
@ -158,43 +187,43 @@ lua <<EOF
-- Abbreviation support -- Abbreviation support
abbreviations = { abbreviations = {
-- Set one of the following to true to enable abbreviations -- Set one of the following to true to enable abbreviations
builtin = false, -- built-in expander builtin = true, -- built-in expander
compe = false, -- nvim-compe source compe = false, -- nvim-compe source
snippets = false, -- snippets.nvim source snippets = false, -- snippets.nvim source
-- additional abbreviations: -- additional abbreviations:
extra = { extra = {
-- Add a \wknight abbreviation to insert -- Add a \wknight abbreviation to insert
-- --
-- Note that the backslash is implied, and that you of -- Note that the backslash is implied, and that you of
-- course may also use a snippet engine directly to do -- course may also use a snippet engine directly to do
-- this if so desired. -- this if so desired.
wknight = '♘', wknight = '♘',
}, },
-- Change if you don't like the backslash -- Change if you don't like the backslash
-- (comma is a popular choice on French keyboards) -- (comma is a popular choice on French keyboards)
leader = '\\', leader = '\\',
}, },
-- Enable suggested mappings? -- Enable suggested mappings?
-- --
-- false by default, true to enable -- false by default, true to enable
mappings = false, mappings = true,
-- Infoview support -- Infoview support
infoview = { infoview = {
-- Automatically open an infoview on entering a Lean buffer? -- Automatically open an infoview on entering a Lean buffer?
autoopen = true, autoopen = true,
-- Set the infoview windows' widths -- Set the infoview windows' widths
width = 50, width = 30,
}, },
-- Progress bar support -- Progress bar support
progress_bars = { progress_bars = {
-- Enable the progress bars? -- Enable the progress bars?
enable = true, enable = true,
-- Use a different priority for the signs -- Use a different priority for the signs
priority = 10, priority = 10,
}, },
} }
EOF EOF

Loading…