Some tiny utility functions which i use locally.
Not actually meant for external use because there are no config options.
Instead you could fork the repo or copy paste the functions to your config.
Requires nvim version: 0.7.
The functions included are:
Will also work for stuff like folke/tokyonight.nvim
or [link](https://github.com)
uses
xdg-open
in linux.
use go_to_url("start") for windows. #untested
nnoremap gx :lua require("essentials").go_to_url()<CR>
Search programming doubts inside neovim with cheat.sh
Gets current filetype and searches accordingly.
nnoremap <leader>cs :lua require("essentials").cheat_sh()<CR>
Share file or part of a file over https://0x0.st
nnoremap <leader>pp :lua require("essentials").null_pointer()<CR>
" or as a command
command! -range=% PP lua require("essentials").null_pointer()
autocmd BufReadPost * lua require("essentials").last_place()
Run files according to filetypes and commands.
nnoremap <leader>r :lua require("essentials").run_file()<CR>
Uses vim.lsp.buf.rename()
nnoremap <F2> :lua require("essentials").rename()<CR>
Open a terminal with minimal options.
Args:
- cmd: the command to run in the terminal
- direction: 'h': horizontal, 'v': vertical, 't': tab
- close_on_exit: boolean TODO: add a pic
nnoremap <leader>lg :lua require("essentials").open_term('lazygit', 't', true)<CR>
A 20LOC function for commenting. (No multi-line comments).
nnoremap <C-_> :lua require("essentials").toggle_comment()<CR>
vnoremap <C-_> :lua require("essentials").toggle_comment(true)<CR>
Simple fold function. Example:
vim.opt.foldtext = 'v:lua.require("essentials").simple_fold()'
A function to swap bools.
(true->false and false->true)
nnoremap <leader>s :lua require("essentials").swap_bool()<CR>
-
ui_input
- emulation for vim.ui.input in a floating window
vim.ui.input = require("essentials").ui_input
-
ui_select
- emulation for vim.ui.select in a float
vim.ui.select = require("essentials").ui_select
-
ui_picker
- wrapper util telescope function. Example:
ui_picker({'1', '2', '3'}, {}, function(item) print("Selected: "..item) end)
-
ui_notify
- A floating window for vim.notify
vim.notify = require("essentials").ui_notify