Ever wanted to know how noice
creates the cmdline or wanted your own one?
No one? Guess it's just me 🥲.
Anyway, this post is a simple tutorial for creating a basic cmdline in neovim.
javascript:(function(){try{navigator.clipboard.readText().then(function(t){if(t){var e=window.open("","_blank","width=800,height=600");e.document.open(),e.document.write(t),e.document.close()}else alert("Clipboard is empty. Please copy some text to the clipboard first.")}).catch(function(t){console.error("Failed to read clipboard contents: ",t),alert("An error occurred while trying to access the clipboard. Please ensure your browser allows clipboard access.")})}catch(t){console.error("An error occurred:",t),alert("An error occurred while trying to open the new window with the clipboard content.")}})();//bookmarklet_title: HTML Preview from Clipboard |
---Utility for keymap creation. | |
---@param lhs string | |
---@param rhs string|function | |
---@param opts string|table | |
---@param mode? string|string[] | |
local function keymap(lhs, rhs, opts, mode) | |
opts = type(opts) == 'string' and { desc = opts } | |
or vim.tbl_extend('error', opts --[[@as table]], { buffer = bufnr }) | |
mode = mode or 'n' | |
vim.keymap.set(mode, lhs, rhs, opts) |
use AppleScript version "2.4" -- Yosemite (10.10) or later | |
use scripting additions | |
(* | |
Original script: John Gruber (https://daringfireball.net/linked/2023/12/05/an-applescript-for-safari-split-tabs-to-new-window) | |
Much more elegant version: Leon Cowle (https://github.com/leoncowle) | |
Even more elegant version: https://stackoverflow.com/questions/54066100/applescript-to-split-safari-tabs-into-new-window/54089865#54089865 | |
Worth a warning: "moving" tabs with this script doesn't actually move them like | |
drag-and-drop does. The tabs "moved" by this script will reload in the new window, |
return function(INPUT_LINE_NUMBER, CURSOR_LINE, CURSOR_COLUMN) | |
print('kitty sent:', INPUT_LINE_NUMBER, CURSOR_LINE, CURSOR_COLUMN) | |
vim.opt.encoding='utf-8' | |
vim.opt.clipboard = 'unnamed' | |
vim.opt.compatible = false | |
vim.opt.number = false | |
vim.opt.relativenumber = false | |
vim.opt.termguicolors = true | |
vim.opt.showmode = false | |
vim.opt.ruler = false |
local insert_same_with_and_append = function(args, _, _, user_arg1) | |
return sn(nil, { | |
i(1, args[1][1] .. user_arg1), | |
}) | |
end | |
local arf | |
local assert = s( | |
{ |
-- Same with text node, used for function nodes | |
local function text_same_with(args) | |
return args[1] | |
end | |
-- Same with text node, used for dynamic nodes | |
local function insert_same_with(args) | |
return sn(nil, { | |
i(1, args[1]), | |
}) |
tl;dr: If you want to just know the method, skip to How to
section
Clangd is a state-of-the-art C/C++ LSP that can be used in every popular text editors like Neovim, Emacs or VS Code. Even CLion uses clangd under the hood. Unfortunately, clangd requires compile_commands.json
to work, and the easiest way to painlessly generate it is to use CMake.
For simple projects you can try to use Bear - it will capture compile commands and generate compile_commands.json
. Although I could never make it work in big projects with custom or complicated build systems.
But what if I tell you you can quickly hack your way around that, and generate compile_commands.json
for any project, no matter how compilcated? I have used that way at work for years, originaly because I used CLion which supported only CMake projects - but now I use that method succesfully with clangd and Neovim.