@@ -18,6 +18,11 @@ let g:pydocstring_doq_path = get(
1818
1919let s: results = []
2020
21+ function ! s: get_indent_width () abort
22+ " Get indentation width
23+ return &smarttab ? &shiftwidth : &softtabstop
24+ endfunction
25+
2126function ! s: get_range () abort
2227 " Get visual mode selection.
2328 let mode = visualmode (1 )
@@ -147,7 +152,7 @@ function! s:create_cmd(style, omissions) abort
147152 \ expand (g: pydocstring_doq_path ),
148153 \ a: style ,
149154 \ g: pydocstring_formatter ,
150- \ & softtabstop
155+ \ s: get_indent_width ()
151156 \ )
152157 else
153158 let cmd = printf (
@@ -156,7 +161,7 @@ function! s:create_cmd(style, omissions) abort
156161 \ a: style ,
157162 \ g: pydocstring_formatter ,
158163 \ a: omissions ,
159- \ & softtabstop
164+ \ s: get_indent_width ()
160165 \ )
161166 endif
162167 if g: pydocstring_templates_path !=# ' '
@@ -169,7 +174,7 @@ endfunction
169174function ! pydocstring#format () abort
170175 let lines = printf (" %s\n " , join (getbufline (bufnr (' %' ), 1 , ' $' ), " \n " ))
171176 let cmd = s: create_cmd (' string' , ' ' )
172- let indent = & softtabstop
177+ let indent = s: get_indent_width ()
173178 let end_lineno = line (' .' )
174179 call s: execute (
175180 \ cmd,
@@ -188,7 +193,7 @@ function! pydocstring#insert(...) abort
188193 let line = getline (' .' )
189194 let indent = matchstr (line , ' ^\(\s*\)' )
190195
191- let space = repeat (' ' , & softtabstop )
196+ let space = repeat (' ' , s: get_indent_width () )
192197 let indent = indent . space
193198 if len (indent ) == 0
194199 let indent = space
0 commit comments