Commit Graph

147 Commits

Author SHA1 Message Date
Jerry Chen
2ffccc286f Match freestanding macros in vim syntax
Any valid name beginning with `#` that isn't already a preprocessor
macro is now considered a freestanding macro. Previously, only
preprocessor macros were handled in the vim syntax file, e.g. `#if`.

For example, this properly handles the syntax for the `#expect` and the
`#require` macros used in Swift Testing.
2025-03-08 12:46:19 -08:00
Erik Eckstein
3ec5d7de24 SIL: replace the is_escaping_closure instruction with destroy_not_escaped_closure
The problem with `is_escaping_closure` was that it didn't consume its operand and therefore reference count checks were unreliable.
For example, copy-propagation could break it.
As this instruction was always used together with an immediately following `destroy_value` of the closure, it makes sense to combine both into a `destroy_not_escaped_closure`.
It
1. checks the reference count and returns true if it is 1
2. consumes and destroys the operand
2025-01-24 19:23:27 +01:00
Saleem Abdulrasool
6443619126 Remove swift-indent tool
This removes the implementation of the `swift-indent` tool, its
associated documentation, and utilities. This tool was never completed
and has much better alternatives with `swift-format` which is more
flexible and actually maintained.
2024-09-19 11:21:59 -07:00
capricorn
3494a23400 [VIM] Fix syntax highlighting of nested comments
This example incorrectly highlights 'foo' as a comment:
/* // */ foo

This example does as well:
// /*
foo
*/ foo
2023-10-27 10:23:25 -06:00
Steven Wu
c1de68976f [Vim] vim syntax update for concurrency keyword
Update swift.vim to contain concurrency keywords like `async` and
`await`.
2023-10-04 09:18:29 -07:00
Meghana Gupta
5d401fb70a Remove select_value SIL instruction 2023-06-13 14:13:43 -07:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Erik Eckstein
6b7ae416e6 SIL: remove unused instructions thin_function_to_pointer and pointer_to_thin_function 2022-03-25 15:44:59 +01:00
Erik Eckstein
383c52aa35 SIL: rename dealloc_ref [stack] -> dealloc_stack_ref
Introduce a new instruction `dealloc_stack_ref ` and remove the `stack` flag from `dealloc_ref`.

The `dealloc_ref [stack]` was confusing, because all it does is to mark the deallocation of the stack space for a stack promoted object.
2022-01-07 16:20:27 +01:00
Erik Eckstein
7849f09e52 SIL: remove the unused alloc_value_buffer, project_value_buffer and dealloc_value_buffer instructions.
Those instructions were use for the materializeForSet implementation, which was replaced by modify-coroutines.
2021-10-07 07:41:54 +02:00
Akshay Hegde
6c38a6b82a Conform to existing conventions for Vim ftplugin
This commit adds standard conventions for Vim filetype plugins:

- Allows users to opt out of using the provided ftplugin file, if they
  choose to install and use another set of runtime files for Swift
  (which offers its own version of ftplugin for Swift), It also prevents
  this ftplugin file from being sourced again if a ftplugin file for
  Swift was already sourced. Vim's documentation on this recommends
  offering users this option as well, under the "DISABLING" section
  of `:help write-filetype-plugin`).

- Adds the `b:undo_ftplugin` buffer local variable, which is used to
  undo the filetype settings when the `:setfiletype` command is used
  (See :help `undo_ftplugin`). Also prefer using the full names for Vim
  settings instead of short ones as they are more readable.

The above conventions are in place in many of the ftplugin files
shipped with Vim, so they can be used as a reference, as well.
2020-12-24 01:01:04 -08:00
Saleem Abdulrasool
20dbe3fb22 vim: handle column and dsohandle identifiers 2020-06-12 10:47:36 -07:00
Saleem Abdulrasool
2b5059c204 vim: handle Any and AnyObject as core types 2020-06-12 10:47:36 -07:00
Saleem Abdulrasool
22006e376c vim: add some missing keywords for highlighting 2020-06-12 10:47:36 -07:00
Saleem Abdulrasool
1d533624c2 vim: treat associatedtype as typealias for highlighting 2020-06-12 10:47:36 -07:00
Saleem Abdulrasool
c505d19045 vim: add differentiability_witness to SIL syntax
Add the keyword from the experimental auto-differentiation functionality.
2020-04-11 10:49:09 -07:00
Emir Sarı
399d74ce1f Add licence notice to Vim syntax files 2020-01-21 22:00:47 +03:00
tokorom
a128b64a35 [vim] replace + to " 2019-11-18 12:40:34 -08:00
tokorom
633986e4db [vim] tidy up coding styles for syntax/swift.vim 2019-11-18 12:40:34 -08:00
Alex Hoppen
932525d762 [gardening] Fix several python-lint warnings 2019-10-29 10:40:20 -07:00
Alex Hoppen
776e2c0030 Revert "Migrate building SwiftSyntax to swift_build_support" 2019-10-29 09:55:32 -07:00
Alex Hoppen
46501b881f [gardening] Fix several python-lint warnings 2019-10-25 15:58:07 -07:00
Argyrios Kyrtzidis
0135e01d02 Rename the swift-format utility to swift-indent
This is to distinguish the C++ indenting functionality from the new formatter that is written in Swift.
2019-07-26 11:40:54 -07:00
Cassie Jones
fea0f4d450 Fix vim comment syntax highlighting.
This change is motivated by highlighting for
test/Interpreter/SDK/lib.swift. It contains the line

    // CHECK: the magic word is ///* magic *///

which without this change leaves the rest of the file highlighted as
commented out.  swiftComment cannot contain swiftLineComment, or else
this:

    /* // */ hello

gets incorrectly highlighted as if "hello" was commented out.
Similarly, swiftLineComment cannot contain swiftComment, or else this:

    // /*
    */

gets incorrectly highlighted as if */ was closing a comment, when
actually it should be a syntax error.
2019-07-22 10:56:52 -07:00
Saleem Abdulrasool
43d98fe8bd vim: improve attribute handling
The attribute can be applied to a typename or a type declaration.
Correct the handling for the second case.
2019-05-26 14:24:43 -07:00
Saleem Abdulrasool
69674eb95a vim: improve the modifier highlighting
This makes the modifier highlighting stand out against the definition
keyword.
2019-05-25 21:47:12 -07:00
Saleem Abdulrasool
1cede8900e vim: improve syntax highlighting for typealias
This improves the detection of syntax so that the identifier for a
typealias is identified as an identifier, the `=` is identified as a
delimiter, and the type that is aliased is identified as a type.
2019-05-24 17:40:36 -07:00
Saleem Abdulrasool
9ac6fe0137 vim: highlight lazy
`lazy` can modify the `var` definition.  Add that as a modifier.
2019-05-15 11:06:47 -07:00
Alex Langford
3d9a28925b [CMake] Modify swift_install_in_component to support cmake install components
CMake supports the notion of installation components. Right now we have some
custom code for supporting swift components. I think that for installation
purposes, it would be nice to use the CMake component system.

This should be a non-functional change. We should still only be generating
install rules for targets and files in components we want to install, and we
still use the install ninja target to install everything.
2019-04-19 14:06:11 -07:00
Saleem Abdulrasool
8a1311d1c3 vim: add open and mutating keywords to SIL
Add a couple of missing modififers to the syntax highlighting for SIL in
vim.
2019-01-26 12:01:07 -08:00
Saleem Abdulrasool
5ead077f85 vim: detect prefix modifier
THe `prefix` modifier applies to prefix operators.  This is used for the
operator definitions, detect the keyword appropriately.
2018-12-31 19:28:32 -08:00
tokorom
472480c118 [vim] Fix default label problem 2018-11-21 11:14:43 +09:00
tokorom
ea2c860ddb [vim] Add swiftDefaultLabelRegion 2018-10-08 14:40:08 +09:00
tokorom
5f3775e319 [vim] Add swiftCaselLabelRegion 2018-10-08 14:37:23 +09:00
tokorom
f037b7edce [vim] add skipempty 2018-09-29 11:09:25 +09:00
tokorom
75b5c11111 [vim] remove nextgroup from swiftTupleIndexNumber 2018-09-26 07:42:29 +09:00
tokorom
fb993301c6 [vim] add swiftTupleIndexNumber 2018-09-26 07:27:40 +09:00
tokorom
b1d4b0be5d [vim] Fix tuple hilight problem with swiftType 2018-09-25 15:58:00 +09:00
tokorom
a67a37ecbb [vim] Add swiftParenthesisRegion 2018-09-25 11:22:53 +09:00
Arnold Schwaighofer
73df12c09f Remove dead constant_string_literal
constant_string_literal was added to support a one word representation
of String that never materialized.
2018-09-05 12:13:57 -07:00
Dave Lee
24123766f6 Fix swiftPreproc regex in swift.vim (#18994) 2018-08-27 16:22:50 -07:00
Erik Eckstein
c6eb5fe82a minor follow-ups for remove pinning in utilities and docs 2018-08-25 11:14:18 -07:00
Arnold Schwaighofer
5940796cc1 SIL: Add an is_escaping_closure instruction
Will be used to verify that withoutActuallyEscaping's block does not
escape the closure.

``%escaping = is_escaping_closure %closure`` tests the reference count. If the
closure is not uniquely referenced it prints out and error message and
returns true. Otherwise, it returns false. The returned result can be
used with a ``cond_fail %escaping`` instruction to abort the program.

rdar://35525730
2018-03-07 08:56:00 -08:00
Harlan
5e02d2a877 Implement #warning and #error (#14048)
* Implement #warning and #error

* Fix #warning/#error in switch statements

* Fix AST printing for #warning/#error

* Add to test case

* Add extra handling to ParseDeclPoundDiagnostic

* fix dumping

* Consume the right paren even in the failure case

* Diagnose extra tokens on the same line after a diagnostic directive
2018-02-03 18:07:05 -05:00
Saleem Abdulrasool
03456c97a7 vim: improve syntax highlighting for SIL attributes
Add rules to highlight the SIL attributes currently emitted by the swift
compiler.
2017-11-01 20:06:41 -07:00
Saleem Abdulrasool
10bc4722c4 vim: improve syntax highlighting for SIL
Highlight identifiers, `sil_stage`, and function attributes.
2017-10-26 22:36:03 -07:00
Saleem Abdulrasool
8268ac87c6 vim: highlight apply in sil properly 2017-10-26 22:35:39 -07:00
Slava Pestov
0acf3ac8d9 SIL: Remove is_nonnull instruction 2017-10-13 17:38:32 -07:00
Slava Pestov
e806b6248d SIL: Remove dynamic_method instruction 2017-10-04 03:53:16 -07:00
Brian Heim
c95598db55 Vim plugin: expand highlighting coverage (#11444)
* vim-syntax: fix highlighting for indirect case/enum

without skipwhite, `indirect enum` never gets highlighted. this
commit also adds the `indirect case` multiword keyword.

* vim-syntax: allow whitespace before type parameters

Added skipwhite to multiple match groups so that whitespace can be used
before type parameters (`Type <Param>`). This matches Xcode's behavior.

* vim-syntax: update last change line

* vim-syntax: remove indirect case from multiword type def group
2017-09-19 10:06:03 -04:00