irongit

My nvim configuration

feat(postgres): env loads database url and function snippet

huncholanehuncholaneauthored
parent 6481285commit 64c928303733f0dab223c6015cabddc11206d2f0Browse files

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 @@
33 "blink.cmp": { "branch": "main", "commit": "40380e711b616a28affb0f4086a2f7de2f2a556b" },
44 "bruno.nvim": { "branch": "main", "commit": "114155856d1ff76ad766efbb66fb270f20006c32" },
55 "crates.nvim": { "branch": "main", "commit": "afcd1cc3eeceb5783676fc8464389b9216a29d05" },
6+ "dotenv.nvim": { "branch": "main", "commit": "7d516e9293c6e3ac21830fb10a4e8674c02747c6" },
67 "flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" },
78 "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
89 "gitsigns.nvim": { "branch": "main", "commit": "20ad4419564d6e22b189f6738116b38871082332" },
@@ -26,6 +27,7 @@
2627 "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" },
2728 "nvim-web-devicons": { "branch": "master", "commit": "8dcb311b0c92d460fac00eac706abd43d94d68af" },
2829 "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
30+ "snacks.nvim": { "branch": "main", "commit": "fe7cfe9800a182274d0f868a74b7263b8c0c020b" },
2931 "telescope-changed-files": { "branch": "main", "commit": "0ccf50680abba21127c46c477f4646f2c5589767" },
3032 "telescope.nvim": { "branch": "master", "commit": "0294ae3eafe662c438addb8692d9c98ef73a983e" },
3133 "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" },
+3-3lua/keymaps.lua
@@ -9,7 +9,7 @@ easymap("n", "<leader>k", ":SafeBD<cr>", "Close Buffer")
99 easymap("n", "<leader>b", ":LastFile<cr>", "Last File")
1010 easymap("n", "<leader>q", ":silent! wa! | silent! qa!<cr>", "Quit")
1111 easymap("n", "<leader>;", "q:", "Elite Cmd")
12-easymap("n", "<leader>f", ":Format<cr>", "Format")
12+easymap("n", "<leader>f", ":Format<cr>", "Format");
1313 easymap("n", "<leader>h", ":nohl<cr>", "Remove Highlights")
1414 easymap("n", "<leader><Space>", ":Telescope find_files<cr>", "Files")
1515 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
146146 -- Extras
147147 easymap({ "i", "n" }, "<C-s>", "<cmd>w<cr>", "Save")
148148 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
44 table.insert(lsplist, file:sub(1, -5))
55 end
66 end
7+
78 vim.lsp.enable(lsplist)
89
910 vim.cmd([[
+3-5lua/plugins.lua
@@ -2,18 +2,16 @@ require("lazy-bootstrap")
22
33 -- These plugins don't need individual files
44 local plugins = {
5+ { "ellisonleao/dotenv.nvim", opts = {} },
56 { "nvim-telescope/telescope.nvim" },
67 { "folke/tokyonight.nvim" },
78 {
89 "mason-org/mason.nvim",
910 opts = {},
1011 },
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",
1612 "tpope/vim-dispatch",
13+ { "nvim-tree/nvim-web-devicons" },
14+ { "windwp/nvim-autopairs", opts = {} },
1715 { "windwp/nvim-ts-autotag", opts = {} },
1816 { "neovim/nvim-lspconfig" },
1917 { "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"
22
33 ---@type LazySpec
44 return {
+3-2lua/plugins/blink.lua
@@ -44,6 +44,7 @@ return {
4444 "rafamadriz/friendly-snippets",
4545 -- "tamago324/nlsp-settings.nvim",
4646 { "onsails/lspkind.nvim", config = lspkind_config },
47+ "kristijanhusak/vim-dadbod-completion",
4748 },
4849 build = "cargo build --release",
4950 opts = {
@@ -51,7 +52,7 @@ return {
5152 sources = {
5253 default = { "lsp", "buffer", "snippets", "path" },
5354 per_filetype = {
54- sql = { "dadbod", "buffer" },
55+ sql = { "dadbod", "buffer", "snippets" },
5556 },
5657 providers = {
5758 path = {
@@ -60,7 +61,7 @@ return {
6061 return vim.fn.getcwd()
6162 end,
6263 },
63- },
64+ },
6465 dadbod = { module = "vim_dadbod_completion.blink" },
6566 },
6667 },
+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+}