mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 16:41:43 +05:30
NeoVIM
- Setup DB query LSP + autocompletion + treesitter - Setup local AI that works with ollama
This commit is contained in:
31
common/.config/nvim/lua/plugins/ai.lua
Normal file
31
common/.config/nvim/lua/plugins/ai.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
return {
|
||||
{
|
||||
"David-Kunz/gen.nvim",
|
||||
opts = {
|
||||
model = "mistral", -- The default model to use.
|
||||
host = "localhost", -- The host running the Ollama service.
|
||||
port = "11434", -- The port on which the Ollama service is listening.
|
||||
display_mode = "float", -- The display mode. Can be "float" or "split".
|
||||
show_prompt = true, -- Shows the Prompt submitted to Ollama.
|
||||
show_model = true, -- Displays which model you are using at the beginning of your chat session.
|
||||
quit_map = "q", -- set keymap for quit
|
||||
no_auto_close = false, -- Never closes the window automatically.
|
||||
init = function()
|
||||
pcall(io.popen, "ollama serve > /dev/null 2>&1 &")
|
||||
end,
|
||||
-- Function to initialize Ollama
|
||||
command = function(options)
|
||||
return "curl --silent --no-buffer -X POST http://" .. options.host .. ":" .. options.port .. "/api/chat -d $body"
|
||||
end,
|
||||
-- The command for the Ollama service. You can use placeholders $prompt, $model and $body (shellescaped).
|
||||
-- This can also be a command string.
|
||||
-- The executed command must return a JSON object with { response, context }
|
||||
-- (context property is optional).
|
||||
-- list_models = '<omitted lua function>', -- Retrieves a list of model names
|
||||
debug = false, -- Prints errors and the command which is run.
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>]", "<cmd>Gen<cr>", desc = "AI Prompt", mode = { "n", "v" } },
|
||||
},
|
||||
},
|
||||
}
|
||||
42
common/.config/nvim/lua/plugins/code-db.lua
Normal file
42
common/.config/nvim/lua/plugins/code-db.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
local function db_completion()
|
||||
require("cmp").setup.buffer({ sources = { { name = "vim-dadbod-completion" } } })
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"tpope/vim-dadbod",
|
||||
opt = true,
|
||||
dependencies = {
|
||||
{ "kristijanhusak/vim-dadbod-ui" },
|
||||
{ "kristijanhusak/vim-dadbod-completion" },
|
||||
},
|
||||
config = function()
|
||||
vim.g.db_ui_save_location = vim.fn.stdpath("config") .. require("plenary.path").path.sep .. "db_ui"
|
||||
vim.g.db_ui_use_nerd_fonts = 1
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {
|
||||
"sql",
|
||||
},
|
||||
command = [[setlocal omnifunc=vim_dadbod_completion#omni]],
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {
|
||||
"sql",
|
||||
"mysql",
|
||||
"plsql",
|
||||
},
|
||||
callback = function()
|
||||
vim.schedule(db_completion)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>qq", desc = "Query UI" },
|
||||
{ "<leader>qq", "<cmd>DBUIToggle<cr>", desc = "Query UI Toggle" },
|
||||
{ "<leader>qa", "<cmd>DBUIAddConnection<cr>", desc = "Query: Add Connection" },
|
||||
{ "<leader>qf", "<cmd>DBUIFindBuffer<cr>", desc = "Query: Find Connection" },
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user