Trying to fix tab completion

This commit is contained in:
Bryan Ramos 2023-06-02 10:02:51 -04:00
parent 29dc93d387
commit b92fff6494

View file

@ -1,7 +1,7 @@
-- Autocmds are automatically loaded on the VeryLazy event -- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua -- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here -- Add any additional autocmds here
local lsp = require('lsp-zero').preset({}) local lsp = require("lsp-zero").preset({})
lsp.on_attach(function(client, bufnr) lsp.on_attach(function(client, bufnr)
lsp.default_keymaps({ buffer = bufnr }) lsp.default_keymaps({ buffer = bufnr })
@ -10,83 +10,91 @@ end)
-- When you don't have mason.nvim installed -- When you don't have mason.nvim installed
-- You'll need to list the servers installed in your system -- You'll need to list the servers installed in your system
lsp.setup_servers({ lsp.setup_servers({
'tsserver', "tsserver",
'eslint', "eslint",
'hls', "hls",
'pyright', "pyright",
'nil_ls', "nil_ls",
'cssls', "cssls",
'html', "html",
'jsonls', "jsonls",
'diagnosticls', "diagnosticls",
'lua_ls', "lua_ls",
'marksman', "marksman",
'purescriptls', "purescriptls",
'tailwindcss', "tailwindcss",
'bashls' "bashls",
}) })
-- (Optional) Configure lua language server for neovim -- (Optional) Configure lua language server for neovim
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls()) require("lspconfig").lua_ls.setup(lsp.nvim_lua_ls())
lsp.setup() lsp.setup()
local cmp = require 'cmp' local cmp = require("cmp")
cmp.setup { cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
require('luasnip').lsp_expand(args.body) require("luasnip").lsp_expand(args.body)
end, end,
}, },
sources = { sources = {
{ name = 'nvim_lsp' }, { name = "nvim_lsp" },
{ name = 'luasnip' }, { name = "luasnip" },
-- other sources... -- other sources...
}, },
-- other configurations... -- other configurations...
} })
vim.cmd [[ vim.cmd([[
au BufRead,BufNewFile *.purs set filetype=purescript au BufRead,BufNewFile *.purs set filetype=purescript
]] ]])
local luasnip = require 'luasnip' local luasnip = require("luasnip")
cmp.setup { cmp.setup({
mapping = { mapping = {
['<Tab>'] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if vim.fn.pumvisible() == 1 then if vim.fn.pumvisible() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-y>', true, true, true), 'n') vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-y>", true, true, true), "n")
elseif luasnip.expand_or_jumpable() then elseif luasnip.expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '') vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else else
fallback() fallback()
end end
end, { 'i', 's' }), end, { "i", "s" }),
['<S-Tab>'] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if vim.fn.pumvisible() == 1 then if vim.fn.pumvisible() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n') vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-p>", true, true, true), "n")
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '') vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
else else
fallback() fallback()
end end
end, { 'i', 's' }), end, { "i", "s" }),
['<CR>'] = cmp.mapping(function(fallback) -- ["<CR>"] = cmp.mapping(function(fallback)
-- fallback()
-- end, { "i", "s" }),
["<CR>"] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
else
fallback() fallback()
end, { 'i', 's' }), end
end,
s = cmp.mapping.confirm({ select = true }),
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
}),
}, },
} })
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
vim.lsp.diagnostic.on_publish_diagnostics, {
-- Disable virtual_text -- Disable virtual_text
virtual_text = false, virtual_text = false,
} })
)
require("notify").setup({ require("notify").setup({
background_colour = "#000000", background_colour = "#000000",