@@ -14,9 +14,6 @@ local M = {}
1414
1515local config = vim .tbl_get (require " astrolsp" , " config" , " file_operations" ) or {}
1616
17- -- TODO: remove check when dropping support for Neovim v0.9
18- local get_clients = vim .lsp .get_clients or vim .lsp .get_active_clients
19-
2017--- @class AstroLSPFileOperationsRename
2118--- @field from string the original filename
2219--- @field to string the new filename
5047--- @param fnames string | string[] a file or list of files that were created
5148function M .didCreateFiles (fnames )
5249 if not vim .tbl_get (config , " operations" , " didCreate" ) then return end
53- for _ , client in pairs (get_clients ()) do
50+ for _ , client in pairs (vim . lsp . get_clients ()) do
5451 local did_create = vim .tbl_get (client , " server_capabilities" , " workspace" , " fileOperations" , " didCreate" )
5552 if did_create then
5653 if type (fnames ) == " string" then fnames = { fnames } end
7067--- @param fnames string | string[] a file or list of files that were deleted
7168function M .didDeleteFiles (fnames )
7269 if not vim .tbl_get (config , " operations" , " didDelete" ) then return end
73- for _ , client in pairs (get_clients ()) do
70+ for _ , client in pairs (vim . lsp . get_clients ()) do
7471 local did_delete = vim .tbl_get (client , " server_capabilities" , " workspace" , " fileOperations" , " didDelete" )
7572 if did_delete ~= nil then
7673 if type (fnames ) == " string" then fnames = { fnames } end
9087--- @param renames AstroLSPFileOperationsRename | AstroLSPFileOperationsRename[] a table or list of tables of files that were renamed
9188function M .didRenameFiles (renames )
9289 if not vim .tbl_get (config , " operations" , " didRename" ) then return end
93- for _ , client in pairs (get_clients ()) do
90+ for _ , client in pairs (vim . lsp . get_clients ()) do
9491 local did_rename = vim .tbl_get (client , " server_capabilities" , " workspace" , " fileOperations" , " didRename" )
9592 if did_rename ~= nil then
9693 if renames .from then renames = { renames } end
120117--- @param fnames string | string[] a file or list of files that will be created
121118function M .willCreateFiles (fnames )
122119 if not vim .tbl_get (config , " operations" , " willCreate" ) then return end
123- for _ , client in pairs (get_clients ()) do
120+ for _ , client in pairs (vim . lsp . get_clients ()) do
124121 local will_create = vim .tbl_get (client , " server_capabilities" , " workspace" , " fileOperations" , " willCreate" )
125122 if will_create then
126123 if type (fnames ) == " string" then fnames = { fnames } end
142139--- @param fnames string | string[] a file or list of files that will be deleted
143140function M .willDeleteFiles (fnames )
144141 if not vim .tbl_get (config , " operations" , " willDelete" ) then return end
145- for _ , client in pairs (get_clients ()) do
142+ for _ , client in pairs (vim . lsp . get_clients ()) do
146143 local will_delete = vim .tbl_get (client , " server_capabilities" , " workspace" , " fileOperations" , " willDelete" )
147144 if will_delete then
148145 if type (fnames ) == " string" then fnames = { fnames } end
164161--- @param renames AstroLSPFileOperationsRename | AstroLSPFileOperationsRename[] a table or list of tables of files that will be renamed
165162function M .willRenameFiles (renames )
166163 if not vim .tbl_get (config , " operations" , " willRename" ) then return end
167- for _ , client in pairs (get_clients ()) do
164+ for _ , client in pairs (vim . lsp . get_clients ()) do
168165 local will_rename = vim .tbl_get (client , " server_capabilities" , " workspace" , " fileOperations" , " willRename" )
169166 if will_rename then
170167 if renames .from then renames = { renames } end
0 commit comments