87 lines
2.2 KiB
VimL
87 lines
2.2 KiB
VimL
" from: https://sharksforarms.dev/posts/neovim-rust/
|
|
" Set completeopt to have a better completion experience
|
|
" :help completeopt
|
|
" menuone: popup even when there's only one match
|
|
" noinsert: Do not insert text until a selection is made
|
|
" noselect: Do not select, force user to select one from the menu
|
|
set completeopt=menuone,noinsert,noselect
|
|
|
|
" Avoid showing extra messages when using completion
|
|
set shortmess+=c
|
|
|
|
" Recognize slint files
|
|
autocmd BufEnter *.slint :setlocal filetype=slint
|
|
|
|
" Setup Completion
|
|
" See https://github.com/hrsh7th/nvim-cmp#basic-configuration
|
|
lua <<EOF
|
|
local cmp = require'cmp'
|
|
cmp.setup({
|
|
-- Enable LSP snippets
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn["vsnip#anonymous"](args.body)
|
|
end,
|
|
},
|
|
mapping = {
|
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
-- Add tab support
|
|
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
|
['<Tab>'] = cmp.mapping.select_next_item(),
|
|
['<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({
|
|
behavior = cmp.ConfirmBehavior.Insert,
|
|
select = true,
|
|
})
|
|
},
|
|
|
|
-- Installed sources
|
|
sources = {
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'vsnip' },
|
|
{ name = 'path' },
|
|
{ name = 'buffer' },
|
|
},
|
|
})
|
|
EOF
|
|
|
|
" Set updatetime for CursorHold
|
|
" ms of no cursor movement to trigger CursorHold
|
|
set updatetime=750
|
|
" Show diagnostic popup on cursor hold
|
|
autocmd CursorHold * lua vim.diagnostic.open_float()
|
|
" have a fixed column for the diagnostics to appear in
|
|
" this removes the jitter when warnings/errors flow in
|
|
set signcolumn=yes
|
|
|
|
let g:LanguageClient_serverCommands = {
|
|
\ 'rust': ['rust-analyzer'],
|
|
\ }
|
|
|
|
lua<<EOF
|
|
vim.g.markdown_fenced_languages = {
|
|
"ts=typescript"
|
|
}
|
|
require("nvim-lsp-installer").setup {}
|
|
local lspconfig = require('lspconfig')
|
|
local util = require('lspconfig.util')
|
|
|
|
lspconfig.denols.setup {
|
|
on_attach = on_attach,
|
|
root_dir = util.root_pattern("deno.json", "deno.jsonc"),
|
|
init_options = {
|
|
enabled = true,
|
|
unstable = true
|
|
}
|
|
}
|
|
|
|
lspconfig.ts_ls.setup {
|
|
on_attach = on_attach,
|
|
root_dir = util.root_pattern("package.json"),
|
|
single_file_support = false
|
|
}
|
|
EOF
|