code-examples/scripts/nvim/init.lua

57 lines
1.2 KiB
Lua

local o = vim.opt
o.compatible = false
o.number = true
o.cmdheight = 2
o.tabstop = 2
o.shiftwidth = 2
o.expandtab = true
vim.cmd('source ~/.config/nvim/bundles/vim-plug/plug.vim')
local Plug = vim.fn['plug#']
vim.call('plug#begin')
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'williamboman/mason.nvim'
Plug 'mfussenegger/nvim-jdtls'
-- Plug('neoclide/coc.nvim', {branch = 'release'})
vim.call('plug#end')
require('mason').setup()
-- local executable = vim.fn[':
vim.api.nvim_create_autocmd({'LspAttach'}, {
pattern = { '*.c', '*.cpp' },
callback = function()
-- vim.api.nvim_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
if (vim.fn['executable']('clangd')) then
vim.lsp.start({
name = 'clangd',
cmd = {'clangd'}
})
end
o.omnifunc = vim.lsp.omnifunc
end
})
vim.api.nvim_create_autocmd({'FileType'}, {
pattern = { 'java' },
callback = function()
local config = {
cmd = { vim.fn.expand('~/.local/share/nvim/mason/bin/jdtls') },
root_dir = vim.fs.dirname(vim.fs.find({ 'gradlew', '.git', 'mvnw' }, { upward = true })[1]),
}
require('jdtls').start_or_attach(config)
o.omnifunc = 'v:lua.vim.lsp.omnifunc'
end
})