Remove data files, cache keywords in a .el file instead

This commit is contained in:
Nathan Lovato
2020-03-23 07:59:20 -06:00
parent 7ce4c220dd
commit 57cbde873c
7 changed files with 5 additions and 716 deletions

View File

@@ -20,7 +20,7 @@ This mode already features all the essentials:
- Automatic pairing of parentheses, brackets, etc.
- Code formatting using
[gdformat](https://github.com/scony/godot-gdscript-toolkit/).
- Auto-completion for all the keywords in the `data/` directory.
- Auto-completion for all the keywords in the `gdscript-keywords.el` file.
## Contributing ##
@@ -78,8 +78,7 @@ Add the following package definition to your `.doom.d/packages.el` file:
```lisp
(package! gdscript-mode
:recipe (:host github
:repo "GDQuest/emacs-gdscript-mode"
:files ("*.el" "data/*.txt")))
:repo "GDQuest/emacs-gdscript-mode"))
```
Require the package in your `.doom.d/config.el` file:
@@ -97,8 +96,7 @@ Add the call to use-package to your Emacs configuration:
:straight (gdscript-mode
:type git
:host github
:repo "GDQuest/emacs-gdscript-mode"
:files ("*.el" "data/*.txt")))
:repo "GDQuest/emacs-gdscript-mode"))
```
## Formatting with gdformat ##

View File

@@ -1,557 +0,0 @@
@GlobalScope
AABB
ARVRAnchor
ARVRCamera
ARVRController
ARVRInterface
ARVROrigin
ARVRPositionalTracker
ARVRServer
AStar
AStar2D
AcceptDialog
AnimatedSprite
AnimatedSprite3D
AnimatedTexture
Animation
AnimationNode
AnimationNodeAdd2
AnimationNodeAdd3
AnimationNodeAnimation
AnimationNodeBlend2
AnimationNodeBlend3
AnimationNodeBlendSpace1D
AnimationNodeBlendSpace2D
AnimationNodeBlendTree
AnimationNodeOneShot
AnimationNodeOutput
AnimationNodeStateMachine
AnimationNodeStateMachinePlayback
AnimationNodeStateMachineTransition
AnimationNodeTimeScale
AnimationNodeTimeSeek
AnimationNodeTransition
AnimationPlayer
AnimationRootNode
AnimationTrackEditPlugin
AnimationTree
AnimationTreePlayer
Area
Area2D
Array
ArrayMesh
AtlasTexture
AudioBusLayout
AudioEffect
AudioEffectAmplify
AudioEffectBandLimitFilter
AudioEffectBandPassFilter
AudioEffectChorus
AudioEffectCompressor
AudioEffectDelay
AudioEffectDistortion
AudioEffectEQ
AudioEffectEQ10
AudioEffectEQ21
AudioEffectEQ6
AudioEffectFilter
AudioEffectHighPassFilter
AudioEffectHighShelfFilter
AudioEffectInstance
AudioEffectLimiter
AudioEffectLowPassFilter
AudioEffectLowShelfFilter
AudioEffectNotchFilter
AudioEffectPanner
AudioEffectPhaser
AudioEffectPitchShift
AudioEffectRecord
AudioEffectReverb
AudioEffectSpectrumAnalyzer
AudioEffectSpectrumAnalyzerInstance
AudioEffectStereoEnhance
AudioServer
AudioStream
AudioStreamGenerator
AudioStreamGeneratorPlayback
AudioStreamMicrophone
AudioStreamPlayback
AudioStreamPlaybackResampled
AudioStreamPlayer
AudioStreamPlayer2D
AudioStreamPlayer3D
AudioStreamRandomPitch
AudioStreamSample
BackBufferCopy
BakedLightmap
BakedLightmapData
BaseButton
Basis
BitMap
BitmapFont
Bone2D
BoneAttachment
BoxContainer
BoxShape
Button
ButtonGroup
CPUParticles
CPUParticles2D
Camera
Camera2D
CameraFeed
CameraServer
CameraTexture
CanvasItem
CanvasItemMaterial
CanvasLayer
CanvasModulate
CapsuleMesh
CapsuleShape
CapsuleShape2D
CenterContainer
CharFXTransform
CheckBox
CheckButton
CircleShape2D
ClassDB
ClippedCamera
CollisionObject
CollisionObject2D
CollisionPolygon
CollisionPolygon2D
CollisionShape
CollisionShape2D
Color
ColorPicker
ColorPickerButton
ColorRect
ConcavePolygonShape
ConcavePolygonShape2D
ConeTwistJoint
ConfigFile
ConfirmationDialog
Container
Control
ConvexPolygonShape
ConvexPolygonShape2D
Crypto
CryptoKey
CubeMap
CubeMesh
Curve
Curve2D
Curve3D
CurveTexture
CylinderMesh
CylinderShape
DampedSpringJoint2D
Dictionary
DirectionalLight
Directory
DynamicFont
DynamicFontData
EditorExportPlugin
EditorFeatureProfile
EditorFileDialog
EditorFileSystem
EditorFileSystemDirectory
EditorImportPlugin
EditorInspector
EditorInspectorPlugin
EditorInterface
EditorNavigationMeshGenerator
EditorPlugin
EditorProperty
EditorResourceConversionPlugin
EditorResourcePreview
EditorResourcePreviewGenerator
EditorSceneImporter
EditorSceneImporterAssimp
EditorScenePostImport
EditorScript
EditorSelection
EditorSettings
EditorSpatialGizmo
EditorSpatialGizmoPlugin
EditorSpinSlider
EditorVCSInterface
EncodedObjectAsID
Engine
Environment
Expression
File
FileDialog
Font
FuncRef
GIProbe
GIProbeData
Generic6DOFJoint
Geometry
GeometryInstance
Gradient
GradientTexture
GraphEdit
GraphNode
GridContainer
GrooveJoint2D
HBoxContainer
HScrollBar
HSeparator
HSlider
HSplitContainer
HTTPClient
HTTPRequest
HashingContext
HeightMapShape
HingeJoint
IP
IP_Unix
Image
ImageTexture
ImmediateGeometry
Input
InputDefault
InputEvent
InputEventAction
InputEventGesture
InputEventJoypadButton
InputEventJoypadMotion
InputEventKey
InputEventMIDI
InputEventMagnifyGesture
InputEventMouse
InputEventMouseButton
InputEventMouseMotion
InputEventPanGesture
InputEventScreenDrag
InputEventScreenTouch
InputEventWithModifiers
InputMap
InstancePlaceholder
InterpolatedCamera
ItemList
JSON
JSONParseResult
JSONRPC
JavaScript
Joint
Joint2D
KinematicBody
KinematicBody2D
KinematicCollision
KinematicCollision2D
Label
LargeTexture
Light
Light2D
LightOccluder2D
Line2D
LineEdit
LineShape2D
LinkButton
Listener
MainLoop
MarginContainer
Marshalls
Material
MenuButton
Mesh
MeshDataTool
MeshInstance
MeshInstance2D
MeshLibrary
MeshTexture
MultiMesh
MultiMeshInstance
MultiMeshInstance2D
MultiplayerAPI
Mutex
Navigation
Navigation2D
NavigationMesh
NavigationMeshInstance
NavigationPolygon
NavigationPolygonInstance
NetworkedMultiplayerPeer
Nil
NinePatchRect
Node
Node2D
NodePath
OS
Object
OccluderPolygon2D
OmniLight
OptionButton
PCKPacker
PHashTranslation
PackedDataContainer
PackedDataContainerRef
PackedScene
PacketPeer
PacketPeerStream
PacketPeerUDP
Panel
PanelContainer
PanoramaSky
ParallaxBackground
ParallaxLayer
Particles
Particles2D
ParticlesMaterial
Path
Path2D
PathFollow
PathFollow2D
Performance
PhysicalBone
Physics2DDirectBodyState
Physics2DDirectBodyStateSW
Physics2DDirectSpaceState
Physics2DServer
Physics2DServerSW
Physics2DShapeQueryParameters
Physics2DShapeQueryResult
Physics2DTestMotionResult
PhysicsBody
PhysicsBody2D
PhysicsDirectBodyState
PhysicsDirectSpaceState
PhysicsMaterial
PhysicsServer
PhysicsShapeQueryParameters
PhysicsShapeQueryResult
PinJoint
PinJoint2D
Plane
PlaneMesh
PlaneShape
PointMesh
Polygon2D
PolygonPathFinder
PoolByteArray
PoolColorArray
PoolIntArray
PoolRealArray
PoolStringArray
PoolVector2Array
PoolVector3Array
Popup
PopupDialog
PopupMenu
PopupPanel
Position2D
Position3D
PrimitiveMesh
PrismMesh
ProceduralSky
ProgressBar
ProjectSettings
ProximityGroup
ProxyTexture
QuadMesh
Quat
RID
RandomNumberGenerator
Range
RayCast
RayCast2D
RayShape
RayShape2D
Rect2
RectangleShape2D
Reference
ReferenceRect
ReflectionProbe
RemoteTransform
RemoteTransform2D
Resource
ResourceFormatLoader
ResourceFormatLoaderCrypto
ResourceFormatSaver
ResourceFormatSaverCrypto
ResourceImporter
ResourceInteractiveLoader
ResourceLoader
ResourcePreloader
ResourceSaver
RichTextEffect
RichTextLabel
RigidBody
RigidBody2D
RootMotionView
SceneState
SceneTree
SceneTreeTimer
Script
ScriptCreateDialog
ScriptEditor
ScrollBar
ScrollContainer
SegmentShape2D
Semaphore
Separator
Shader
ShaderMaterial
Shape
Shape2D
ShortCut
Skeleton
Skeleton2D
SkeletonIK
Skin
SkinReference
Sky
Slider
SliderJoint
SoftBody
Spatial
SpatialGizmo
SpatialMaterial
SpatialVelocityTracker
SphereMesh
SphereShape
SpinBox
SplitContainer
SpotLight
SpringArm
Sprite
Sprite3D
SpriteBase3D
SpriteFrames
StaticBody
StaticBody2D
StreamPeer
StreamPeerBuffer
StreamPeerSSL
StreamPeerTCP
StreamTexture
String
StyleBox
StyleBoxEmpty
StyleBoxFlat
StyleBoxLine
StyleBoxTexture
SurfaceTool
TCP_Server
TabContainer
Tabs
TextEdit
TextFile
Texture
Texture3D
TextureArray
TextureButton
TextureLayered
TextureProgress
TextureRect
Theme
Thread
TileMap
TileSet
Timer
ToolButton
TouchScreenButton
Transform
Transform2D
Translation
TranslationServer
Tree
TreeItem
TriangleMesh
Tween
UndoRedo
VBoxContainer
VScrollBar
VSeparator
VSlider
VSplitContainer
Variant
Vector2
Vector3
VehicleBody
VehicleWheel
VideoPlayer
VideoStream
Viewport
ViewportContainer
ViewportTexture
VisibilityEnabler
VisibilityEnabler2D
VisibilityNotifier
VisibilityNotifier2D
VisualInstance
VisualServer
VisualShader
VisualShaderNode
VisualShaderNodeBooleanConstant
VisualShaderNodeBooleanUniform
VisualShaderNodeColorConstant
VisualShaderNodeColorFunc
VisualShaderNodeColorOp
VisualShaderNodeColorUniform
VisualShaderNodeCompare
VisualShaderNodeCubeMap
VisualShaderNodeCubeMapUniform
VisualShaderNodeCustom
VisualShaderNodeDeterminant
VisualShaderNodeDotProduct
VisualShaderNodeExpression
VisualShaderNodeFaceForward
VisualShaderNodeFresnel
VisualShaderNodeGlobalExpression
VisualShaderNodeGroupBase
VisualShaderNodeIf
VisualShaderNodeInput
VisualShaderNodeIs
VisualShaderNodeOuterProduct
VisualShaderNodeOutput
VisualShaderNodeScalarClamp
VisualShaderNodeScalarConstant
VisualShaderNodeScalarDerivativeFunc
VisualShaderNodeScalarFunc
VisualShaderNodeScalarInterp
VisualShaderNodeScalarOp
VisualShaderNodeScalarSmoothStep
VisualShaderNodeScalarSwitch
VisualShaderNodeScalarUniform
VisualShaderNodeSwitch
VisualShaderNodeTexture
VisualShaderNodeTextureUniform
VisualShaderNodeTextureUniformTriplanar
VisualShaderNodeTransformCompose
VisualShaderNodeTransformConstant
VisualShaderNodeTransformDecompose
VisualShaderNodeTransformFunc
VisualShaderNodeTransformMult
VisualShaderNodeTransformUniform
VisualShaderNodeTransformVecMult
VisualShaderNodeUniform
VisualShaderNodeVec3Constant
VisualShaderNodeVec3Uniform
VisualShaderNodeVectorClamp
VisualShaderNodeVectorCompose
VisualShaderNodeVectorDecompose
VisualShaderNodeVectorDerivativeFunc
VisualShaderNodeVectorDistance
VisualShaderNodeVectorFunc
VisualShaderNodeVectorInterp
VisualShaderNodeVectorLen
VisualShaderNodeVectorOp
VisualShaderNodeVectorRefract
VisualShaderNodeVectorScalarMix
VisualShaderNodeVectorScalarSmoothStep
VisualShaderNodeVectorScalarStep
VisualShaderNodeVectorSmoothStep
WeakRef
WindowDialog
World
World2D
WorldEnvironment
X509Certificate
XMLParser
YSort
bool
float

View File

@@ -1,4 +0,0 @@
INF
NAN
PI
TAU

View File

@@ -1,70 +0,0 @@
Color8
abs
acos
asin
assert
atan
atan2
bytes2var
ceil
char
clamp
convert
cos
cosh
db2linear
decimals
dectime
deg2rad
dict2inst
ease
exp
floor
fmod
fposmod
funcref
hash
inst2dict
instance_from_id
is_inf
is_nan
lerp
linear2db
load
log
max
min
name
nearest_po2
pow
preload
print
print_stack
printerr
printraw
prints
printt
rad2deg
rand_range
rand_seed
randf
randi
randomize
range
round
seed
sign
sin
sinh
sqrt
stepify
str
str2var
tan
tanh
type_exists
typeof
var2bytes
var2str
weakref
yield

View File

@@ -1,5 +0,0 @@
bool
float
int
null
void

View File

@@ -1,43 +0,0 @@
and
as
assert
break
breakpoint
case
class
class_name
const
continue
do
elif
else
enum
export
extends
false
for
func
if
in
is
master
match
not
onready
or
pass
preload
remote
return
self
setget
signal
slave
static
switch
sync
tool
true
var
while
yield

View File

@@ -30,37 +30,7 @@
;;; Code:
(defun gdscript--get-file-content-as-string (file-path-relative)
"Return the content of a file in this package as a list of strings.
FILE-PATH-RELATIVE is the path of the data file to parse relative
to this package. Used to retrieve lists of keywords for syntax
highlighting.
If the file isn't available, the function tries to access the
file without the directory path. This is for compatibility with
the Doom Emacs distribution, which flattens the package's
structure."
(with-temp-buffer
(let (this-directory requested-path file-path)
(setq this-directory (file-name-directory (or load-file-name buffer-file-name)))
(setq requested-path (concat this-directory file-path-relative))
(setq file-path (if (file-readable-p requested-path)
requested-path
(concat this-directory
(file-name-nondirectory file-path-relative))))
(insert-file-contents file-path)
(split-string (buffer-string)
"\n"
t))))
(defconst gdscript-keywords (eval-when-compile (gdscript--get-file-content-as-string "data/keywords.txt")))
(defconst gdscript-built-in-constants (eval-when-compile (gdscript--get-file-content-as-string "data/built-in-constants.txt")))
;; Only contains types that are not classes and that the Godot editor highlights
;; like built-in keywords
(defconst gdscript-built-in-types (eval-when-compile (gdscript--get-file-content-as-string "data/built-in-types.txt")))
(defconst gdscript-built-in-functions (eval-when-compile (gdscript--get-file-content-as-string "data/built-in-functions.txt")))
;; Contains all engine classes and node types, including vectors, transforms, etc.
(defconst gdscript-built-in-classes (eval-when-compile (gdscript--get-file-content-as-string "data/built-in-classes.txt")))
(require 'gdscript-keywords)
(defun regex-maker (words)
(regexp-opt words 'symbols))
@@ -142,7 +112,7 @@ The type returned can be `comment', `string' or `paren'."
((rx (or "\"\"\"" "'''"))
(0 (ignore (gdscript-syntax-stringify))))))
(define-inline gdscript-syntax-count-quotes (quote-char &optional point limit)
(defun gdscript-syntax-count-quotes (quote-char &optional point limit)
"Count number of quotes around point (max is 3).
QUOTE-CHAR is the quote char to count. Optional argument POINT is
the point where scan starts (defaults to current point), and LIMIT