Skip to main content

Example configuration

This is an example configuration for kulala.

This helps you get started with kulala and provides a basic configuration to use it.

Configuration file

Create ftplugin/http.lua in your configuration directory.

This file will be loaded when you open a file with the http filetype.

Execute request

Add the following code to ftplugin/http.lua to run the http request when you press Enter.

vim.api.nvim_buf_set_keymap(
0,
"n",
"<CR>",
"<cmd>lua require('kulala').run()<cr>",
{ noremap = true, silent = true, desc = "Execute the request" }
)

Jump between requests

Add the following code to ftplugin/http.lua to jump between requests when you press ] and [.

vim.api.nvim_buf_set_keymap(
0,
"n",
"[",
"<cmd>lua require('kulala').jump_prev()<cr>",
{ noremap = true, silent = true, desc = "Jump to the previous request" }
)
vim.api.nvim_buf_set_keymap(
0,
"n",
"]",
"<cmd>lua require('kulala').jump_next()<cr>",
{ noremap = true, silent = true, desc = "Jump to the next request" }
)

Inspect the current request

Add the following code to ftplugin/http.lua to inspect the current request when you press <leader>i.

vim.api.nvim_buf_set_keymap(
0,
"n",
"<leader>i",
"<cmd>lua require('kulala').inspect()<cr>",
{ noremap = true, silent = true, desc = "Inspect the current request" }
)

Toggle body and headers

Add the following code to ftplugin/http.lua to toggle between body and headers when you press <leader>t.

vim.api.nvim_buf_set_keymap(
0,
"n",
"<leader>t",
"<cmd>lua require('kulala').toggle_view()<cr>",
{ noremap = true, silent = true, desc = "Toggle between body and headers" }
)

Copy as curl

Add the following code to ftplugin/http.lua to copy the current request as a curl command when you press <leader>co.

tip

Mnemonic: co for curl out.

vim.api.nvim_buf_set_keymap(
0,
"n",
"<leader>co",
"<cmd>lua require('kulala').copy()<cr>",
{ noremap = true, silent = true, desc = "Copy the current request as a curl command" }
)

Insert from curl

Add the following code to ftplugin/http.lua to insert from a curl command in your clipboard when you press <leader>ci.

tip

Mnemonic: ci for curl in.

vim.api.nvim_buf_set_keymap(
0,
"n",
"<leader>ci",
"<cmd>lua require('kulala').from_curl()<cr>",
{ noremap = true, silent = true, desc = "Paste curl from clipboard as http request" }
)