My nvim configuration
feat(postgres): env loads database url and function snippet
9 files changed, +69 -11
+4-0after/ftplugin/sql.lua
| @@ -0,0 +1,4 @@ | ||
| 1 | +vim.bo.shiftwidth = 2 | |
| 2 | +vim.bo.tabstop = 2 | |
| 3 | +vim.bo.softtabstop = 2 | |
| 4 | +vim.bo.expandtab = true |
+2-0lazy-lock.json
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | "blink.cmp": { "branch": "main", "commit": "40380e711b616a28affb0f4086a2f7de2f2a556b" }, |
| 4 | 4 | "bruno.nvim": { "branch": "main", "commit": "114155856d1ff76ad766efbb66fb270f20006c32" }, |
| 5 | 5 | "crates.nvim": { "branch": "main", "commit": "afcd1cc3eeceb5783676fc8464389b9216a29d05" }, |
| 6 | + "dotenv.nvim": { "branch": "main", "commit": "7d516e9293c6e3ac21830fb10a4e8674c02747c6" }, | |
| 6 | 7 | "flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" }, |
| 7 | 8 | "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, |
| 8 | 9 | "gitsigns.nvim": { "branch": "main", "commit": "20ad4419564d6e22b189f6738116b38871082332" }, |
| @@ -26,6 +27,7 @@ | ||
| 26 | 27 | "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, |
| 27 | 28 | "nvim-web-devicons": { "branch": "master", "commit": "8dcb311b0c92d460fac00eac706abd43d94d68af" }, |
| 28 | 29 | "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, |
| 30 | + "snacks.nvim": { "branch": "main", "commit": "fe7cfe9800a182274d0f868a74b7263b8c0c020b" }, | |
| 29 | 31 | "telescope-changed-files": { "branch": "main", "commit": "0ccf50680abba21127c46c477f4646f2c5589767" }, |
| 30 | 32 | "telescope.nvim": { "branch": "master", "commit": "0294ae3eafe662c438addb8692d9c98ef73a983e" }, |
| 31 | 33 | "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, |
+3-3lua/keymaps.lua
| @@ -9,7 +9,7 @@ easymap("n", "<leader>k", ":SafeBD<cr>", "Close Buffer") | ||
| 9 | 9 | easymap("n", "<leader>b", ":LastFile<cr>", "Last File") |
| 10 | 10 | easymap("n", "<leader>q", ":silent! wa! | silent! qa!<cr>", "Quit") |
| 11 | 11 | easymap("n", "<leader>;", "q:", "Elite Cmd") |
| 12 | -easymap("n", "<leader>f", ":Format<cr>", "Format") | |
| 12 | +easymap("n", "<leader>f", ":Format<cr>", "Format"); | |
| 13 | 13 | easymap("n", "<leader>h", ":nohl<cr>", "Remove Highlights") |
| 14 | 14 | easymap("n", "<leader><Space>", ":Telescope find_files<cr>", "Files") |
| 15 | 15 | easymap("n", "<leader>/", ":Telescope live_grep<cr>", "Live Grep") |
| @@ -146,5 +146,5 @@ vim.keymap.set({ "x", "o" }, "ae", ":<C-u>normal! ggVG<CR>", { desc = "around en | ||
| 146 | 146 | -- Extras |
| 147 | 147 | easymap({ "i", "n" }, "<C-s>", "<cmd>w<cr>", "Save") |
| 148 | 148 | easymap({ "i", "n" }, "<C-p>", vim.diagnostic.open_float, "Open Diagnostic Float") |
| 149 | -easymap("n", ";", "A;", "Add ; to the end") | |
| 150 | -easymap("n", ",", "A,", "Add , to the end") | |
| 149 | +-- easymap("n", ";", "A;", "Add ; to the end") | |
| 150 | +-- easymap("n", ",", "A,", "Add , to the end") |
+1-0lua/options.lua
| @@ -4,6 +4,7 @@ for _, file in ipairs(vim.fn.readdir(vim.fn.stdpath("config") .. "/lsp")) do | ||
| 4 | 4 | table.insert(lsplist, file:sub(1, -5)) |
| 5 | 5 | end |
| 6 | 6 | end |
| 7 | + | |
| 7 | 8 | vim.lsp.enable(lsplist) |
| 8 | 9 | |
| 9 | 10 | vim.cmd([[ |
+3-5lua/plugins.lua
| @@ -2,18 +2,16 @@ require("lazy-bootstrap") | ||
| 2 | 2 | |
| 3 | 3 | -- These plugins don't need individual files |
| 4 | 4 | local plugins = { |
| 5 | + { "ellisonleao/dotenv.nvim", opts = {} }, | |
| 5 | 6 | { "nvim-telescope/telescope.nvim" }, |
| 6 | 7 | { "folke/tokyonight.nvim" }, |
| 7 | 8 | { |
| 8 | 9 | "mason-org/mason.nvim", |
| 9 | 10 | opts = {}, |
| 10 | 11 | }, |
| 11 | - { "nvim-tree/nvim-web-devicons" }, | |
| 12 | - { "windwp/nvim-autopairs", opts = {} }, | |
| 13 | - "tpope/vim-dadbod", | |
| 14 | - "kristijanhusak/vim-dadbod-completion", | |
| 15 | - "kristijanhusak/vim-dadbod-ui", | |
| 16 | 12 | "tpope/vim-dispatch", |
| 13 | + { "nvim-tree/nvim-web-devicons" }, | |
| 14 | + { "windwp/nvim-autopairs", opts = {} }, | |
| 17 | 15 | { "windwp/nvim-ts-autotag", opts = {} }, |
| 18 | 16 | { "neovim/nvim-lspconfig" }, |
| 19 | 17 | { "saecki/crates.nvim", tag = "stable", opts = {} }, |
+1-1lua/plugins/auto-session.lua
| @@ -1,4 +1,4 @@ | ||
| 1 | -vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" | |
| 1 | +vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" | |
| 2 | 2 | |
| 3 | 3 | ---@type LazySpec |
| 4 | 4 | return { |
+3-2lua/plugins/blink.lua
| @@ -44,6 +44,7 @@ return { | ||
| 44 | 44 | "rafamadriz/friendly-snippets", |
| 45 | 45 | -- "tamago324/nlsp-settings.nvim", |
| 46 | 46 | { "onsails/lspkind.nvim", config = lspkind_config }, |
| 47 | + "kristijanhusak/vim-dadbod-completion", | |
| 47 | 48 | }, |
| 48 | 49 | build = "cargo build --release", |
| 49 | 50 | opts = { |
| @@ -51,7 +52,7 @@ return { | ||
| 51 | 52 | sources = { |
| 52 | 53 | default = { "lsp", "buffer", "snippets", "path" }, |
| 53 | 54 | per_filetype = { |
| 54 | - sql = { "dadbod", "buffer" }, | |
| 55 | + sql = { "dadbod", "buffer", "snippets" }, | |
| 55 | 56 | }, |
| 56 | 57 | providers = { |
| 57 | 58 | path = { |
| @@ -60,7 +61,7 @@ return { | ||
| 60 | 61 | return vim.fn.getcwd() |
| 61 | 62 | end, |
| 62 | 63 | }, |
| 63 | - }, | |
| 64 | + }, | |
| 64 | 65 | dadbod = { module = "vim_dadbod_completion.blink" }, |
| 65 | 66 | }, |
| 66 | 67 | }, |
+25-0lua/plugins/dbui.lua
| @@ -0,0 +1,25 @@ | ||
| 1 | +---@type LazySpec | |
| 2 | +return { | |
| 3 | + { | |
| 4 | + "kristijanhusak/vim-dadbod-ui", | |
| 5 | + dependencies = { | |
| 6 | + "tpope/vim-dadbod", | |
| 7 | + "ellisonleao/dotenv.nvim", | |
| 8 | + "kristijanhusak/vim-dadbod-completion", | |
| 9 | + }, | |
| 10 | + config = function() | |
| 11 | + vim.g.db = vim.env.DATABASE_URL | |
| 12 | + | |
| 13 | + local group = vim.api.nvim_create_augroup("dbui", { clear = true }) | |
| 14 | + vim.api.nvim_create_autocmd("FileType", { | |
| 15 | + pattern = "sql", | |
| 16 | + group = group, | |
| 17 | + callback = function() | |
| 18 | + vim.cmd("Dotenv") | |
| 19 | + vim.keymap.set("n", "<leader>r", ":DB < %<CR>", { buffer = true, desc = "Run File" }) | |
| 20 | + vim.keymap.set("v", "<leader>r", ":DB<CR>", { buffer = true, desc = "Run File" }) | |
| 21 | + end, | |
| 22 | + }) | |
| 23 | + end, | |
| 24 | + }, | |
| 25 | +} |
+27-0snippets/sql.json
| @@ -0,0 +1,27 @@ | ||
| 1 | +{ | |
| 2 | + "Postgres Function": { | |
| 3 | + "prefix": [ | |
| 4 | + "pf", | |
| 5 | + "postgres-function" | |
| 6 | + ], | |
| 7 | + "description": "Create a postgres function.", | |
| 8 | + "body": [ | |
| 9 | + "CREATE OR REPLACE FUNCTION ${1:name}(${2:vars})", | |
| 10 | + "RETURNS ${3:return_type}", | |
| 11 | + "LANGUAGE plpgsql", | |
| 12 | + "AS \\$\\$", | |
| 13 | + "BEGIN", | |
| 14 | + " ${4:logic}", | |
| 15 | + "END; \\$\\$;" | |
| 16 | + ] | |
| 17 | + }, | |
| 18 | + "New Template": { | |
| 19 | + "prefix": [ | |
| 20 | + "new-template" | |
| 21 | + ], | |
| 22 | + "description": "description", | |
| 23 | + "body": [ | |
| 24 | + "body" | |
| 25 | + ] | |
| 26 | + } | |
| 27 | +} |