diff --git a/lua/t0xa/plugins/dadbod.lua b/lua/t0xa/plugins/dadbod.lua new file mode 100644 index 0000000..dc5d76b --- /dev/null +++ b/lua/t0xa/plugins/dadbod.lua @@ -0,0 +1,5 @@ +return { + "tpope/vim-dadbod", + "kristijanhusak/vim-dadbod-completion", + "kristijanhusak/vim-dadbod-ui", +} diff --git a/lua/t0xa/plugins/nvim-cmp.lua b/lua/t0xa/plugins/nvim-cmp.lua index 5009fe2..557a061 100644 --- a/lua/t0xa/plugins/nvim-cmp.lua +++ b/lua/t0xa/plugins/nvim-cmp.lua @@ -1,83 +1,90 @@ return { - "hrsh7th/nvim-cmp", - event = "InsertEnter", -- Only load plugin when in INSERT mode - dependencies = { - "hrsh7th/cmp-buffer", -- source for text in buffer - "hrsh7th/cmp-path", -- source for file system paths - { - "L3MON4D3/LuaSnip", - -- follow latest release. - version = "v2.*", -- Replace by the latest released major (first number of latest release) - }, - "saadparwaiz1/cmp_luasnip", -- for autocompletion - "rafamadriz/friendly-snippets", -- useful snippets - "onsails/lspkind.nvim", -- vs-code like pictograms - }, - config = function() - -- Load custom snippets from path - require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_vscode").lazy_load({ paths = vim.fn.stdpath("config") .. "/snippets/" }) + "hrsh7th/nvim-cmp", + event = "InsertEnter", -- Only load plugin when in INSERT mode + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + { + "L3MON4D3/LuaSnip", + -- follow latest release. + version = "v2.*", -- Replace by the latest released major (first number of latest release) + }, + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + }, + config = function() + -- Load custom snippets from path + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load({ paths = vim.fn.stdpath("config") .. "/snippets/" }) - local cmp = require("cmp") - local luasnip = require("luasnip") - local lspkind = require("lspkind") + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") - -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) - require("luasnip.loaders.from_vscode").lazy_load() + -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) + require("luasnip.loaders.from_vscode").lazy_load() - cmp.setup({ - completion = { - completeopt = "menu,menuone,preview,noselect", - }, - snippet = { -- configure how nvim-cmp interacts with snippet engine - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.locally_jumpable(1) then - luasnip.jump(1) - else - fallback() - end - end, { "i", "s" }), + cmp.setup({ + completion = { + completeopt = "menu,menuone,preview,noselect", + }, + snippet = { -- configure how nvim-cmp interacts with snippet engine + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.locally_jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - -- sources for autocompletion - -- !! Priority is important - autocompletion will be ordered from top to bottom - sources = cmp.config.sources({ - { name = "nvim_lsp" }, -- nvim LSP servers - { name = "luasnip" }, -- snippets - { name = "buffer" }, -- text within current buffer - { name = "path" }, -- file system paths - }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + -- sources for autocompletion + -- !! Priority is important - autocompletion will be ordered from top to bottom + sources = cmp.config.sources({ + { name = "nvim_lsp" }, -- nvim LSP servers + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), - -- configure lspkind for vs-code like pictograms in completion menu - formatting = { - format = lspkind.cmp_format({ - maxwidth = 50, - ellipsis_char = "...", - }), - }, - }) - end, + -- configure lspkind for vs-code like pictograms in completion menu + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, + }) + + cmp.setup.filetype({ "sql" }, { + sources = { + { name = "vim-dadbod-completion" }, + { name = "buffer" } + } + }) + end, }