feat: auto-highlight on mouse hover and yank
This commit is contained in:
@@ -37,7 +37,7 @@ you can run the configured Neovim binary with just:
|
|||||||
nix run git+https://forge.capytal.company/dot013/nvim
|
nix run git+https://forge.capytal.company/dot013/nvim
|
||||||
|
|
||||||
# GitHub mirror
|
# GitHub mirror
|
||||||
niix run github:dot013/nvim
|
nix run github:dot013/nvim
|
||||||
```
|
```
|
||||||
|
|
||||||
It also can be used as a NixOS or [Home-Manager](https://github.com/nix-community/home-manager)
|
It also can be used as a NixOS or [Home-Manager](https://github.com/nix-community/home-manager)
|
||||||
|
|||||||
@@ -41,6 +41,9 @@
|
|||||||
neovim = pkgs.callPackage ./package.nix {
|
neovim = pkgs.callPackage ./package.nix {
|
||||||
mdfmt = self.packages.${stdenv.hostPlatform.system}.mdfmt;
|
mdfmt = self.packages.${stdenv.hostPlatform.system}.mdfmt;
|
||||||
};
|
};
|
||||||
|
godot-neovim = pkgs.writeShellApplication {
|
||||||
|
name = "godot-neovim";
|
||||||
|
};
|
||||||
mdfmt = pkgs.buildGoModule {
|
mdfmt = pkgs.buildGoModule {
|
||||||
name = "mdfmt";
|
name = "mdfmt";
|
||||||
src = inputs.mdfmt;
|
src = inputs.mdfmt;
|
||||||
|
|||||||
@@ -86,3 +86,49 @@ vim.diagnostic.config({
|
|||||||
|
|
||||||
require("dot.keymaps")
|
require("dot.keymaps")
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
|
desc = "Highlight when yanking text",
|
||||||
|
group = vim.api.nvim_create_augroup("dot-highlight-yank", { clear = true }),
|
||||||
|
callback = function()
|
||||||
|
vim.hl.on_yank()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
group = vim.api.nvim_create_augroup("dot-lsp-attach-autocmds", { clear = true }),
|
||||||
|
callback = function(e)
|
||||||
|
local client = vim.lsp.get_client_by_id(e.data.client_id)
|
||||||
|
|
||||||
|
-- Highlight references of word under cursor when it rests for a little while
|
||||||
|
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight, e.buf) then
|
||||||
|
local highlight_augroup = vim.api.nvim_create_augroup("dot-lsp-highlight", { clear = false })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||||
|
buffer = e.buf,
|
||||||
|
callback = vim.lsp.buf.document_highlight,
|
||||||
|
group = highlight_augroup,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||||
|
buffer = e.buf,
|
||||||
|
callback = vim.lsp.buf.clear_references,
|
||||||
|
group = highlight_augroup,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("LspDetach", {
|
||||||
|
callback = function(e2)
|
||||||
|
vim.lsp.buf.clear_references()
|
||||||
|
vim.api.nvim_clear_autocmds({ group = "dot-lsp-attach-autocmds", buffer = e2.buf })
|
||||||
|
end,
|
||||||
|
group = vim.api.nvim_create_augroup("dot-lsp-detach-autocmds", { clear = true }),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Toggle inlay hints
|
||||||
|
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint, e.buf) then
|
||||||
|
vim.keymap.set("n", "<leader>lh", function()
|
||||||
|
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = e.buf }))
|
||||||
|
end, { desc = "LSP: [T]oggle Inlay [H]ints" })
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|||||||
75
scripts/godot-neovim.sh
Normal file
75
scripts/godot-neovim.sh
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Script provided by Mathijs Bakker's godotdev.nvim, licensed under the Apache
|
||||||
|
# License Version 2.0.
|
||||||
|
#
|
||||||
|
# A copy of the original script can be found at
|
||||||
|
# https://github.com/Mathijs-Bakker/godotdev.nvim/blob/79d9315988b7772c03a1cabb6f31f5287c849e2b/doc/neovim-external-editor-setup.md#installation
|
||||||
|
#
|
||||||
|
# A copy of the original license can be found at
|
||||||
|
# https://github.com/Mathijs-Bakker/godotdev.nvim/blob/79d9315988b7772c03a1cabb6f31f5287c849e2b/LICENSE
|
||||||
|
|
||||||
|
# Godot → Neovim launcher with GUI terminal focus
|
||||||
|
# Usage:
|
||||||
|
# godot-nvr.sh [terminal_name] +{line} {file} [--tab|--vsplit]
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Arguments
|
||||||
|
# -----------------------------
|
||||||
|
DEFAULT_TERMINAL="${DEFAULT_TERMINAL:=ghostty}"
|
||||||
|
ARG0="$1"
|
||||||
|
|
||||||
|
if [[ "$ARG0" == +* || "$ARG0" == --* || -f "$ARG0" ]]; then
|
||||||
|
# No terminal argument provided, use default
|
||||||
|
GODOT_TERMINAL="$DEFAULT_TERMINAL"
|
||||||
|
else
|
||||||
|
# First argument is terminal name
|
||||||
|
GODOT_TERMINAL="$ARG0"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
SOCKET="${SOCKET:=/tmp/godot.pipe}" # Neovim socket path
|
||||||
|
NVR="${NVR:=/Library/Frameworks/Python.framework/Versions/3.8/bin/nvr}"
|
||||||
|
|
||||||
|
OPEN_MODE="window"
|
||||||
|
LINE=""
|
||||||
|
FILE=""
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Parse remaining arguments
|
||||||
|
# -----------------------------
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--tab) OPEN_MODE="tab"; shift ;;
|
||||||
|
--vsplit) OPEN_MODE="vsplit"; shift ;;
|
||||||
|
+[0-9]*) LINE="${1#+}"; shift ;;
|
||||||
|
*) FILE="$1"; shift ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
[ -z "$FILE" ] && exit 0
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Open file in Neovim or jump to buffer
|
||||||
|
# -----------------------------
|
||||||
|
if $NVR --servername "$SOCKET" --remote-expr \
|
||||||
|
"bufexists(fnamemodify('$FILE', ':p'))" | grep -q 1; then
|
||||||
|
CMD=":buffer $(basename "$FILE")"
|
||||||
|
else
|
||||||
|
case "$OPEN_MODE" in
|
||||||
|
window) CMD=":e $FILE" ;;
|
||||||
|
tab) CMD=":tabedit $FILE" ;;
|
||||||
|
vsplit) CMD=":vsplit $FILE" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -n "$LINE" ] && CMD="$CMD | call cursor($LINE,1)"
|
||||||
|
CMD="$CMD | normal! zz"
|
||||||
|
|
||||||
|
$NVR --servername "$SOCKET" --remote-send "<C-\\><C-N>${CMD}<CR>"
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Focus GUI terminal (Hyprland)
|
||||||
|
# -----------------------------
|
||||||
|
hyprctl dispatch focuswindow class:$GODOT_TERMINAL
|
||||||
|
|
||||||
Reference in New Issue
Block a user