@@ -74,12 +74,16 @@ M.get_text_term = function(get_text_opts, on_exit_cb)
7474 -- increase the number of columns temporary so that the width is used during the
7575 -- terminal command kitty @ get-text. this avoids hard wrapping lines to the
7676 -- current window size. Note: a larger min_cols appears to impact performance
77- -- defer is used as a timing workaround because this is expected to be called right before termopen
77+ -- defer is used as a timing workaround because this is expected to be called right before
78+ -- opening the terminal
7879 p .orig_columns = defer_resize_term (300 )
7980
80- -- set the shell used for termopen to sh to avoid imcompatabiliies with other shells (e.g., nushell, fish, etc)
81+ -- set the shell used to sh to avoid imcompatabiliies with other shells (e.g., nushell, fish, etc)
8182 vim .o .shell = ' sh'
82- local success , error = pcall (vim .fn .termopen , full_cmd , {
83+
84+ local open_term_fn = vim .fn .jobstart
85+ local open_term_options = {
86+ term = true ,
8387 stdout_buffered = true ,
8488 stderr_buffered = true ,
8589 on_stdout = function (_ , data )
@@ -112,7 +116,7 @@ M.get_text_term = function(get_text_opts, on_exit_cb)
112116
113117 if error_index > 0 then
114118 ksb_util .display_error (scrollback_cmd , {
115- entrypoint = ' termopen () :: exit_code = 0 and error_index > 0' ,
119+ entrypoint = ' open_term_fn () :: exit_code = 0 and error_index > 0' ,
116120 full_cmd = full_cmd ,
117121 code = 1 , -- exit code is not returned through pipe but we can assume 1 due to error message
118122 channel_id = id ,
@@ -139,23 +143,29 @@ M.get_text_term = function(get_text_opts, on_exit_cb)
139143 :gsub (' ;k=s' , ' ' )
140144 or nil
141145 ksb_util .display_error (full_cmd , {
142- entrypoint = ' termopen () :: exit_code ~= 0' ,
146+ entrypoint = ' open_term_fn () :: exit_code ~= 0' ,
143147 code = exit_code ,
144148 channel_id = id ,
145149 stdout = out ,
146150 stderr = stderr and table.concat (stderr , ' \n ' ) or nil ,
147151 }, error_header )
148152 end
149153 end ,
150- })
154+ }
155+ if vim .fn .has (' nvim-0.11' ) <= 0 then
156+ open_term_fn = vim .fn .termopen
157+ open_term_options .term = nil
158+ end
159+
160+ local success , error = pcall (open_term_fn , full_cmd , open_term_options )
151161 if not success then
152162 ksb_util .display_error (full_cmd , {
153- entrypoint = ' termopen () :: pcall(vim.fn.termopen ) error returned' ,
163+ entrypoint = ' open_term_fn () :: pcall(open_term_fn ) error returned' ,
154164 stderr = error or nil ,
155165 }, error_header )
156166 end
157167
158- -- restore the original shell after processing termopen
168+ -- restore the original shell after processing
159169 vim .o .shell = p .orig_options .shell
160170end
161171
0 commit comments