This commit is contained in:
Christian Nieves
2023-08-04 18:16:46 +00:00
parent a23d3e359a
commit e3c702a55d
6 changed files with 48 additions and 73 deletions

View File

@ -1,6 +1,19 @@
local use_google = require("utils").use_google local use_google = require("utils").use_google
return { return {
-- {
-- "rcarriga/nvim-notify",
-- config = function()
-- local colors = require("catppuccin.palettes").get_palette()
-- require("notify").setup({
-- background_colour = colors.base,
-- fps = 10, -- default 30
-- stages = "slide", -- default fade_in_slide_out
-- timeout = 5000, -- default 5000
-- })
-- vim.notify = require("notify")
-- end,
-- },
-- Pretty symbols -- Pretty symbols
{ {
"nvim-tree/nvim-web-devicons", "nvim-tree/nvim-web-devicons",

View File

@ -8,10 +8,6 @@ local has_words_before = function()
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
return { return {
{ {
"tzachar/cmp-tabnine", "tzachar/cmp-tabnine",
@ -29,6 +25,7 @@ return {
dependencies = { dependencies = {
"f3fora/cmp-spell", "f3fora/cmp-spell",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"amarakon/nvim-cmp-buffer-lines",
"hrsh7th/cmp-calc", "hrsh7th/cmp-calc",
"onsails/lspkind.nvim", "onsails/lspkind.nvim",
"hrsh7th/cmp-cmdline", "hrsh7th/cmp-cmdline",
@ -37,41 +34,37 @@ return {
"hrsh7th/cmp-nvim-lsp-document-symbol", "hrsh7th/cmp-nvim-lsp-document-symbol",
"hrsh7th/cmp-nvim-lsp-signature-help", "hrsh7th/cmp-nvim-lsp-signature-help",
"hrsh7th/cmp-nvim-lua", "hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-path", "FelipeLema/cmp-async-path",
"lukas-reineke/cmp-under-comparator", "lukas-reineke/cmp-under-comparator",
"ray-x/cmp-treesitter", "ray-x/cmp-treesitter",
}, },
config = function() config = function()
vim.opt.shortmess:append("c")
vim.opt.completeopt = { "menu", "menuone", "noselect" }
local cmp = require("cmp") local cmp = require("cmp")
local conditionalSources = cmp.config.sources({ local conditionalSources = cmp.config.sources({
{ name = "nvim_lsp", priority = 100 }, { name = "nvim_lsp", priority = 8 },
{ name = "nvim_lsp_signature_help", priority = 6 }, { name = "treesitter", priority = 7 },
{ name = "luasnip", priority = 7 }, { name = "nvim_lsp_signature_help" },
{ name = "luasnip" },
{ name = "calc" }, { name = "calc" },
{ name = "crates" }, { name = "crates" },
{ name = "nvim_lua" }, { name = "nvim_lua" },
{ name = "emoji" }, { name = "emoji" },
{ name = "path" }, { name = "async_path" },
{ name = "treesitter" }, { name = "spell" },
{ { name = "buffer", option = { keyword_pattern = [[\k\+]] }, priority = 1 },
name = "spell", -- { name = "buffer-lines" },
option = {
keep_all_entries = false,
enable_in_context = function()
return true
end,
},
},
{ name = "buffer", max_item_count = 5, keyword_length = 5 },
}) })
if use_google() then if use_google() then
require("cmp_nvim_ciderlsp").setup() require("cmp_nvim_ciderlsp").setup()
table.insert(conditionalSources, { name = "analysislsp" }) table.insert(conditionalSources, { name = "analysislsp", priority = 5 })
table.insert(conditionalSources, { name = "nvim_ciderlsp", priority = 80 }) table.insert(conditionalSources, { name = "nvim_ciderlsp", priority = 9 })
else else
table.insert(conditionalSources, { name = "cmp_tabnine" }) table.insert(conditionalSources, { name = "cmp_tabnine", priority = 9 })
end end
local lspkind = require("lspkind") local lspkind = require("lspkind")
@ -81,8 +74,9 @@ return {
cmp.setup.cmdline({ "/", "?" }, { cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp_document_symbol" }, { name = "nvim_lsp_document_symbol", priority = 3 },
{ name = "buffer", max_item_count = 5 }, { name = "treesitter", priority = 2 },
{ name = "buffer", option = { keyword_pattern = [[\k\+]] }, priority = 1 },
}), }),
}) })
@ -90,8 +84,9 @@ return {
cmp.setup.cmdline(":", { cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "path", priority = 9 }, { name = "async_path", priority = 9 },
{ name = "cmdline" }, { name = "treesitter", priority = 7 },
{ name = "cmdline", priority = 8 },
}), }),
}) })
@ -101,7 +96,6 @@ return {
["<C-u>"] = cmp.mapping.scroll_docs(4), ["<C-u>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.close(), ["<C-e>"] = cmp.mapping.close(),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-m>"] = cmp.mapping.confirm({ select = true }),
["<CR>"] = cmp.mapping.confirm({ select = true }), ["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
@ -136,11 +130,12 @@ return {
end), end),
}, },
preselect = cmp.PreselectMode.None,
sources = conditionalSources, sources = conditionalSources,
sorting = { sorting = {
comparators = { comparators = {
-- cmp.config.compare.priority, cmp.config.compare.priority,
cmp.config.compare.offset, cmp.config.compare.offset,
cmp.config.compare.exact, cmp.config.compare.exact,
cmp.config.compare.score, cmp.config.compare.score,
@ -160,19 +155,8 @@ return {
formatting = { formatting = {
format = lspkind.cmp_format({ format = lspkind.cmp_format({
mode = "symbol_text", -- mode = "symbol_text",
before = function(entry, vim_item) -- maxwidth = 50, -- half max width
if entry.source.name == "nvim_ciderlsp" then
if entry.completion_item.is_multiline then
-- multi-line specific formatting here
vim_item.menu = "  "
else
vim_item.menu = ""
end
end
return vim_item
end,
maxwidth = 50, -- half max width
menu = { menu = {
nvim_ciderlsp = "", nvim_ciderlsp = "",
buffer = "", buffer = "",
@ -181,7 +165,7 @@ return {
nvim_lua = "", nvim_lua = "",
luasnip = "[LuaSnip]", luasnip = "[LuaSnip]",
cmp_tabnine = "[TabNine]", cmp_tabnine = "[TabNine]",
path = "[path]", async_path = "[async_path]",
tmux = "[TMUX]", tmux = "[TMUX]",
}, },
}), }),

View File

@ -33,10 +33,6 @@ return {
local lsp_status = require("lsp-status") local lsp_status = require("lsp-status")
lsp_status.register_progress() lsp_status.register_progress()
-- Don't show the dumb matching stuff
vim.opt.shortmess:append("c")
vim.opt.completeopt = { "menu", "menuone", "noselect" }
vim.opt.spell = true vim.opt.spell = true
vim.opt.spelllang = { "en_us" } vim.opt.spelllang = { "en_us" }
vim.lsp.handlers["window/showMessage"] = function(_, result, ctx) vim.lsp.handlers["window/showMessage"] = function(_, result, ctx)
@ -73,10 +69,7 @@ return {
"bzl", "bzl",
"typescript", "typescript",
}, },
-- required for proto generated files jump root_dir = lspconfig.util.root_pattern("google3/*BUILD"),
root_dir = function(fname)
return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$")
end,
settings = {}, settings = {},
}, },
} }
@ -104,9 +97,7 @@ return {
"typescript", "typescript",
"javascript", "javascript",
}, },
root_dir = function(fname) root_dir = lspconfig.util.root_pattern("google3/*BUILD"),
return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$")
end,
settings = {}, settings = {},
}, },
} }
@ -126,7 +117,7 @@ return {
}, },
codeDescriptionSupport = true, codeDescriptionSupport = true,
dataSupport = true, dataSupport = true,
layeredDiagnostics = true, -- layeredDiagnostics = true,
} }
capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities) capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities)

View File

@ -4,14 +4,15 @@ return {
lazy = false, lazy = false,
config = function() config = function()
vim.diagnostic.config({ vim.diagnostic.config({
-- virtual_lines = { only_current_line = true }, virtual_lines = { only_current_line = true },
virtual_lines = true, -- virtual_lines = true,
-- update_in_insert = true, update_in_insert = true,
virtual_text = false, virtual_text = false,
}) })
require("lsp_lines").setup() require("lsp_lines").setup()
require("lsp_lines").toggle()
end, end,
keys = { keys = {
{ {

View File

@ -1,13 +0,0 @@
return {
"rcarriga/nvim-notify",
config = function()
local colors = require("catppuccin.palettes").get_palette()
require("notify").setup({
background_colour = colors.base,
fps = 10, -- default 30
stages = "slide", -- default fade_in_slide_out
timeout = 5000, -- default 5000
})
vim.notify = require("notify")
end,
}

View File

@ -72,10 +72,9 @@ set scrolloff=3 " Minumum lines to keep above and below cursor
" \ }, " \ },
" \ cache_enabled: 1, " \ cache_enabled: 1,
" \ } " \ }
set shortmess=A set shortmess=A " disable swap
set shortmess+=O set shortmess+=O
set modifiable set modifiable
set omnifunc= completeopt=menuone,noinsert,noselect
set updatetime=100 set updatetime=100