Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/vimPublic

runtime(ftplugin): make ft-typescript use javascript.vim#17168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
brianhuster wants to merge2 commits intovim:master
base:master
Choose a base branch
Loading
frombrianhuster:ft-javascript

Conversation

brianhuster
Copy link
Contributor

@brianhusterbrianhuster commentedApr 20, 2025
edited
Loading

Typescript (and JavascriptReact, TypescriptReact) are just super-sets of Javascript. So to avoid duplication, I think we should make them source ft-javascript.

I would like some reviews from@dkearns@chrisbra

Typescript (and JavascriptReact, TypescriptReact) are just super-sets ofJavascript. So to avoid duplication, we should make them sourceft-javascript.
@@ -0,0 +1,14 @@
" Change the :browse e filter to primarily show JavaScript-related files.
if (has("gui_win32")||has("gui_gtk"))&&!exists("b:browsefilter")
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This snippet is moved fromjavascript.vim to here.

I am not sure if it is a good idea to filter Javascript-like files only. Because in web development, we could also use HTML, CSS, EJS beside Javascript.

Not to say that this behavior is not documented (which means it is unexpected to users), so should this be removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I am not sure if it is a good idea to filter Javascript-like files only. Because in web development, we could also use HTML, CSS, EJS beside Javascript.

I agree it's useful to include related files, and have a local copy adding HTML and CSS, but it was never clear where to stop with this. It seems reasonable to limit the filters to the actual filetype and utilise the "All Files" filter for anything else.

Are you suggesting the order should be changed to default to "All files"? That's the default behaviour but the filetype plugins have always put that last, I think.

vim/src/vim.h

Lines 2509 to 2525 in31b78cc

#ifdefFEAT_BROWSE
# ifdefBACKSLASH_IN_FILENAME
# defineBROWSE_FILTER_MACROS \
(char_u *)N_("Vim macro files (*.vim)\t*.vim\nAll Files (*.*)\t*.*\n")
# defineBROWSE_FILTER_ALL_FILES (char_u *)N_("All Files (*.*)\t*.*\n")
# defineBROWSE_FILTER_DEFAULT \
(char_u *)N_("All Files (*.*)\t*.*\nC source (*.c, *.h)\t*.c;*.h\nC++ source (*.cpp, *.hpp)\t*.cpp;*.hpp\nVB code (*.bas, *.frm)\t*.bas;*.frm\nVim files (*.vim, _vimrc, _gvimrc)\t*.vim;_vimrc;_gvimrc\n")
# else
# defineBROWSE_FILTER_MACROS \
(char_u *)N_("Vim macro files (*.vim)\t*.vim\nAll Files (*)\t*\n")
# defineBROWSE_FILTER_ALL_FILES (char_u *)N_("All Files (*)\t*\n")
# defineBROWSE_FILTER_DEFAULT \
(char_u *)N_("All Files (*)\t*\nC source (*.c, *.h)\t*.c;*.h\nC++ source (*.cpp, *.hpp)\t*.cpp;*.hpp\nVim files (*.vim, _vimrc, _gvimrc)\t*.vim;_vimrc;_gvimrc\n")
# endif
# defineBROWSE_SAVE 1 // flag for do_browse()
# defineBROWSE_DIR 2 // flag for do_browse()
#endif

Not to say that this behavior is not documented (which means it is unexpected to users), so should this be removed?

I'm not sure what needs to be documented as the filtering is discoverable simply by opening the file dialog. Rather than remove it, I think abrowsefilter value should be set for all filetypes.

Copy link
ContributorAuthor

@brianhusterbrianhusterApr 23, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't have a strong opinion on whether to keep it or remove it or add what, but I think this kind of behavior should be documented and consistent between different filetypes.

I'm not sure what needs to be documented as the filtering is discoverable simply by opening the file dialog.

I would never know what kind of filetypes it filters without trying it several times. That is bad UX.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You mean the(has("gui_win32") || has("gui_gtk")) ? Or what exactly should be documented? The browsefilter variable is defined for "Windows, GTK and the Motif UI". But although Motif GUI supports the browsefilter variable, there is no easy way to switch different filters. So restricting it togui_win32 orgui_gtk makes sense.

setlocalsuffixesadd+=.ts,.d.ts,.tsx,.js,.jsx,.cjs,.mjs

letb:undo_ftplugin="setl fo< com< cms< sua<"
runtime! ftplugin/javascript.vim
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does it make sense to set the omnifunc from Javascript also for Typescript? Similar for the 'define' option and matchit values?

Copy link
Contributor

@KonfektKonfektApr 21, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For what it's worth, I came up with these settings for typescript, but@romainl surely has better founded ideas on their right values

setlocalinclude=^\\s*\\%(import\\|export\\).*\\<from\\>\\s*['\"]\\zs[^'\"\\r\\n]\\+\\ze['\"]\\|\\<require(\\s*['\"]\\zs[^'\"\\r\\n]\\+\\ze['\"]let &l:define='^\s*\('\..'\(export\s\)*\(default\s\)*\(var\|const\|let\|function\|class\|interface\)\s'\..'\|\(public\|private\|protected\|readonly\|static\)\s'\..'\|\(get\s\|set\s\)'\..'\|\(export\sdefault\s\|abstract\sclass\s\)'\..'\|\(async\s\)'\..'\|\(\ze\i\+([^)]*).*{$\)'\..'\)'ifexists('b:match_words')letb:match_words.=','elseletb:match_words=''endifletb:match_words='\<function\>:\<return\>,'\..'\<do\>:\<while\>,'\..'\<switch\>:\<case\>:\<default\>,'\..'\<if\>:\<else\>,'\..'\<try\>:\<catch\>:\<finally\>'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Copy link
ContributorAuthor

@brianhusterbrianhusterMay 5, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I also have an includeexpr that can even jump to Node moduleshttps://github.com/brianhuster/dotfiles/blob/main/.config/nvim/after/ftplugin/javascript.vim

But I don't think it will be very useful because of#16707, and alsolanguage server covers this feature well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

language server covers this feature well.

Ctags and Language Servers take you further, but we're here to max out Vim's built-in functionalities. This reminds me ofzzzyxwvut/java-vim#4 (comment) ; even if&include sometimes breaks ongf, its principal use is including other files for grepping#16916 (comment)

Copy link
ContributorAuthor

@brianhusterbrianhusterMay 5, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

but we're here to max out Vim's built-in functionalities

Just think how many people use the built-in omnifunc of JavaScript in 2025?

I will not add it to this PR, but if you want to do it for your own PR, you are free to do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

noone even did anything, until I did.

That's commendable, keep up the good work

I will not add it to this PR, but if you want to do it for your own PR, you are free to do that.

Okay, one step after another.

Copy link
ContributorAuthor

@brianhusterbrianhusterMay 5, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Btw, a formatexpr forVimscript andhelp will be nice, I think these Vim's specific languages need "maximized Vim functionalities" the most.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, makes sense, a separate issue. For help.vim, there'sHelpFormatExpr floating around

brianhuster reacted with thumbs up emojibrianhuster reacted with eyes emoji
@Konfekt
Copy link
Contributor

Since python and other plug-ins sport these as well, how aboutmappings to move between functions

@brianhuster
Copy link
ContributorAuthor

how aboutmappings to move between functions

I see many mappings, I think we should only choose 2 operations and map to[[ and]].

But anyway, it's not purpose of this PR, so I think that should be discussed in another issue

Konfekt reacted with thumbs up emoji

@Konfekt
Copy link
Contributor

Konfekt commentedApr 21, 2025
edited
Loading

I see many mappings, I think we should only choose 2 operations and map to [[ and ]]

Yes, in principle. What confuses me a bit in general is the distinction between navigating between methods]/[m, say in Java, and functions in C[/] that depend on a certain formatting. But I agree that this better be treated separately

@brianhusterbrianhuster marked this pull request as draftMay 2, 2025 14:27
Konfekt added a commit to Konfekt/yats.vim that referenced this pull requestMay 5, 2025
@chrisbra
Copy link
Member

are you still working on that@brianhuster ?

@brianhuster
Copy link
ContributorAuthor

I don't abandon this, but it's true that this is not very high in my priority list (since this is just a refactor, not a fix). So anyone can take over this

@chrisbra
Copy link
Member

thanks and no worries. Take your time, it may just push down in my attention list :)

@brianhuster
Copy link
ContributorAuthor

Btw, based on the test, it seems thatsetfiletype_completion is not working right (it shouldn't complete values that contain an underscore)

@brianhuster
Copy link
ContributorAuthor

Could I put the filejavascript_extra.vim inftplugin/javascript/extra.vim?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dkearnsdkearnsdkearns left review comments

@chrisbrachrisbrachrisbra left review comments

+1 more reviewer

@KonfektKonfektKonfekt left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@brianhuster@Konfekt@chrisbra@dkearns

[8]ページ先頭

©2009-2025 Movatter.jp