From 6bc21bed5caa0ba239e2353343f801cb8249cbc8 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 22 Apr 2023 13:11:12 +1000 Subject: [PATCH 1/2] fix(#2157): use stdpath cache for my_on_attach.lua --- doc/nvim-tree-lua.txt | 10 ++++++---- lua/nvim-tree/keymap-legacy.lua | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index e44a5446ab8..901a316cac7 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -194,9 +194,10 @@ Requirements *:NvimTreeGenerateOnAttach* - Creates and opens a new file `/tmp/my_on_attach.lua` containing an - |nvim-tree.on_attach| function based on your |nvim-tree.view.mappings|, - |nvim-tree.remove_keymaps| as well as the defaults. + Creates and opens a new file `my_on_attach.lua` in |stdpath| `"cache"`, + usually `$XDG_CACHE_HOME/nvim`. Contains |nvim-tree.on_attach| function based + on your |nvim-tree.view.mappings|, |nvim-tree.remove_keymaps| as well as the + defaults. See https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach ============================================================================== @@ -1218,7 +1219,8 @@ Experimental features that may become default or optional functionality. Configuration for diagnostic logging. *nvim-tree.log.enable* - Enable logging to a file `$XDG_CACHE_HOME/nvim/nvim-tree.log` + Enable logging to a file `nvim-tree.log` in |stdpath| `"cache"`, usually + `$XDG_CACHE_HOME/nvim` Type: `boolean`, Default: `false` *nvim-tree.log.truncate* diff --git a/lua/nvim-tree/keymap-legacy.lua b/lua/nvim-tree/keymap-legacy.lua index b28e692b6cd..5c494cc484d 100644 --- a/lua/nvim-tree/keymap-legacy.lua +++ b/lua/nvim-tree/keymap-legacy.lua @@ -2,6 +2,7 @@ local api = require "nvim-tree.api" local open_file = require "nvim-tree.actions.node.open-file" local keymap = require "nvim-tree.keymap" local notify = require "nvim-tree.notify" +local utils = require "nvim-tree.utils" local M = { -- only populated when legacy mappings active @@ -401,7 +402,7 @@ function M.cmd_generate_on_attach() return end - local name = "/tmp/my_on_attach.lua" + local name = utils.path_join { vim.fn.stdpath "cache", "my_on_attach.lua" } local file = io.output(name) io.write(M.on_attach_lua) io.close(file) From 3210ee325f8e57c33ccfdb6f4aa4a12cb4f30850 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 23 Apr 2023 13:07:07 +1000 Subject: [PATCH 2/2] fix(#2157): my_on_attach.lua -> nvim-tree-on-attach.lua --- doc/nvim-tree-lua.txt | 2 +- lua/nvim-tree/keymap-legacy.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 9a2226ed790..2d3cab36730 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -194,7 +194,7 @@ Requirements *:NvimTreeGenerateOnAttach* - Creates and opens a new file `my_on_attach.lua` in |stdpath| `"cache"`, + Creates and opens a new file `nvim-tree-on-attach.lua` in |stdpath| `"cache"`, usually `$XDG_CACHE_HOME/nvim`. Contains |nvim-tree.on_attach| function based on your |nvim-tree.view.mappings|, |nvim-tree.remove_keymaps| as well as the defaults. diff --git a/lua/nvim-tree/keymap-legacy.lua b/lua/nvim-tree/keymap-legacy.lua index 5c494cc484d..a57490a746a 100644 --- a/lua/nvim-tree/keymap-legacy.lua +++ b/lua/nvim-tree/keymap-legacy.lua @@ -402,7 +402,7 @@ function M.cmd_generate_on_attach() return end - local name = utils.path_join { vim.fn.stdpath "cache", "my_on_attach.lua" } + local name = utils.path_join { vim.fn.stdpath "cache", "nvim-tree-on-attach.lua" } local file = io.output(name) io.write(M.on_attach_lua) io.close(file)