Skip to content

Some tiny functions which i use regularly in neovim. Not a plugin per se.

License

Notifications You must be signed in to change notification settings

tamton-aquib/essentials.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 

Repository files navigation

essentials.nvim

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:

Go to url under the cursor

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

go_to_url_2

nnoremap gx :lua require("essentials").go_to_url()<CR>

Search results from cht.sh

Search programming doubts inside neovim with cheat.sh

Gets current filetype and searches accordingly.

cheat_sheet

nnoremap <leader>cs :lua require("essentials").cheat_sh()<CR>

null_pointer

Share file or part of a file over https://0x0.st

null_pointer

nnoremap <leader>pp :lua require("essentials").null_pointer()<CR>
" or as a command
command! -range=% PP lua require("essentials").null_pointer()

Go to the last place when opening a buffer

autocmd BufReadPost * lua require("essentials").last_place()

Run different files

Run files according to filetypes and commands.

run_file_2

nnoremap <leader>r :lua require("essentials").run_file()<CR>

VSCode like floating rename window.

Uses vim.lsp.buf.rename()

rename

nnoremap <F2> :lua require("essentials").rename()<CR>

Open terminal

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>

Simple Commenting function

A 20LOC function for commenting. (No multi-line comments).

toggle_comment

nnoremap <C-_> :lua require("essentials").toggle_comment()<CR>
vnoremap <C-_> :lua require("essentials").toggle_comment(true)<CR>

A smol fold function.

Simple fold function. Example:

simple_fold

vim.opt.foldtext = 'v:lua.require("essentials").simple_fold()'

Swap Booleans

A function to swap bools.

(true->false and false->true)

swap_bool

nnoremap <leader>s :lua require("essentials").swap_bool()<CR>

Util Functions

  • 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

About

Some tiny functions which i use regularly in neovim. Not a plugin per se.

Topics

Resources

License

Stars

Watchers

Forks

Languages