Skip to content

Commit 13c7146

Browse files
authored
fix(#2157): use stdpath cache for nvim-tree-on-attach.lua (#2159)
* fix(#2157): use stdpath cache for my_on_attach.lua * fix(#2157): my_on_attach.lua -> nvim-tree-on-attach.lua
1 parent d68b00a commit 13c7146

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

doc/nvim-tree-lua.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ Requirements
194194

195195
*:NvimTreeGenerateOnAttach*
196196

197-
Creates and opens a new file `/tmp/my_on_attach.lua` containing an
198-
|nvim-tree.on_attach| function based on your |nvim-tree.view.mappings|,
199-
|nvim-tree.remove_keymaps| as well as the defaults.
197+
Creates and opens a new file `nvim-tree-on-attach.lua` in |stdpath| `"cache"`,
198+
usually `$XDG_CACHE_HOME/nvim`. Contains |nvim-tree.on_attach| function based
199+
on your |nvim-tree.view.mappings|, |nvim-tree.remove_keymaps| as well as the
200+
defaults.
200201
See https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach
201202

202203
==============================================================================
@@ -1219,7 +1220,8 @@ In the event of a problem please disable the experiment and raise an issue.
12191220
Configuration for diagnostic logging.
12201221

12211222
*nvim-tree.log.enable*
1222-
Enable logging to a file `$XDG_CACHE_HOME/nvim/nvim-tree.log`
1223+
Enable logging to a file `nvim-tree.log` in |stdpath| `"cache"`, usually
1224+
`$XDG_CACHE_HOME/nvim`
12231225
Type: `boolean`, Default: `false`
12241226

12251227
*nvim-tree.log.truncate*

lua/nvim-tree/keymap-legacy.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local api = require "nvim-tree.api"
22
local open_file = require "nvim-tree.actions.node.open-file"
33
local keymap = require "nvim-tree.keymap"
44
local notify = require "nvim-tree.notify"
5+
local utils = require "nvim-tree.utils"
56

67
local M = {
78
-- only populated when legacy mappings active
@@ -401,7 +402,7 @@ function M.cmd_generate_on_attach()
401402
return
402403
end
403404

404-
local name = "/tmp/my_on_attach.lua"
405+
local name = utils.path_join { vim.fn.stdpath "cache", "nvim-tree-on-attach.lua" }
405406
local file = io.output(name)
406407
io.write(M.on_attach_lua)
407408
io.close(file)

0 commit comments

Comments
 (0)