summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-08-19 11:56:52 -0600
committerJosh Rahm <rahm@google.com>2022-08-19 11:56:52 -0600
commit496be085b855d0192753d933313536929671a9d3 (patch)
treee7767aa31688654faaa047f2a905ad444865ac7b /plugin
parent57171e2191fa769d15d2a33db13703d239cb4acf (diff)
downloadrneovim-userregs-496be085b855d0192753d933313536929671a9d3.tar.gz
rneovim-userregs-496be085b855d0192753d933313536929671a9d3.tar.bz2
rneovim-userregs-496be085b855d0192753d933313536929671a9d3.zip
Change basename to exclude the extension
Diffstat (limited to 'plugin')
-rw-r--r--plugin/basename.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/plugin/basename.lua b/plugin/basename.lua
index 81cc971..8b875d1 100644
--- a/plugin/basename.lua
+++ b/plugin/basename.lua
@@ -1,7 +1,10 @@
-- Implementation of the basename register.
--
-- The basename register is like the filename register ("%), but instead of
--- returning the whole filename, it will return just the basename.
+-- returning the whole filename, it will return just the basename with one
+-- extension removed.
+--
+-- Useful for Java when needing to reference the class.
--
-- This register is assigned to the character '$'
@@ -11,11 +14,11 @@ local api = vim.api
local handler = {}
function handler.do_yank(self, content)
- return
+ return -1 -- Read-only register.
end
function handler.do_put()
- return vim.fn.expand('%:t')
+ return vim.fn.expand('%:t:r')
end
userreg.register_handler('$', handler)