mirror of https://github.com/fredrikekre/.dotfiles
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.3 KiB
65 lines
2.3 KiB
set runtimepath^=~/.vim runtimepath+=~/.vim/after |
|
let &packpath = &runtimepath |
|
source ~/.vimrc |
|
|
|
lua << EOF |
|
|
|
-- Setup nvim-cmp. |
|
vim.opt.completeopt = {"menu", "menuone", "noselect"} |
|
|
|
local cmp = require'cmp' |
|
|
|
cmp.setup({ |
|
snippet = { |
|
expand = function(args) |
|
require('luasnip').lsp_expand(args.body) -- For `luasnip` users. |
|
end, |
|
}, |
|
mapping = { |
|
-- ['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), |
|
-- ['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), |
|
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), |
|
-- ['<C-y>'] = cmp.config.enable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping. |
|
-- ['<C-e>'] = cmp.mapping({ |
|
-- i = cmp.mapping.abort(), |
|
-- c = cmp.mapping.close(), |
|
-- }), |
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. |
|
}, |
|
sources = cmp.config.sources({ |
|
{ name = 'nvim_lsp' }, |
|
{ name = 'luasnip' }, -- For luasnip users. |
|
}, |
|
{ |
|
{ name = 'buffer' }, |
|
}) |
|
}) |
|
|
|
-- Setup lspconfig: capabilities is passed to lspconfig.$server.setup |
|
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) |
|
|
|
-- Set LSP keymappings in on_attach (i.e. only in buffers with LSP active) |
|
local on_attach = function(client, bufnr) |
|
opts = { noremap=true, silent=true } |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) |
|
end |
|
|
|
-- Julia LSP (LanguageServer.jl) |
|
require'lspconfig'.julials.setup({ |
|
on_new_config = function(new_config, _) |
|
local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") |
|
if require'lspconfig'.util.path.is_file(julia) then |
|
new_config.cmd[1] = julia |
|
end |
|
end, |
|
-- This just adds dirname(fname) as a fallback (see nvim-lspconfig#1768). |
|
root_dir = function(fname) |
|
local util = require'lspconfig.util' |
|
return util.root_pattern 'Project.toml'(fname) or util.find_git_ancestor(fname) or |
|
util.path.dirname(fname) |
|
end, |
|
on_attach = on_attach, |
|
capabilities = capabilities, |
|
}) |
|
|
|
EOF
|
|
|