Reorganize modules
This commit is contained in:
parent
50ea98319f
commit
f453b3cee1
55 changed files with 0 additions and 1535 deletions
178
modules/lang/javascript/+screeps.el
Normal file
178
modules/lang/javascript/+screeps.el
Normal file
|
@ -0,0 +1,178 @@
|
|||
;;; custom-screeps.el
|
||||
|
||||
(defconst screeps-objects
|
||||
'("ConstructionSite" "Creep" "Flag" "Game" "Memory" "Mineral" "Nuke"
|
||||
"OwnedStructure" "PathFinder" "RawMemory" "Resource" "Room"
|
||||
"RoomObject" "RoomPosition" "Source"
|
||||
|
||||
"Structure" "StructureController" "StructureExtension"
|
||||
"StructureExtractor" "StructureKeeperLair" "StructureLab"
|
||||
"StructureLink" "StructureNuker" "StructureObserver"
|
||||
"StructurePortal" "StructurePowerBank" "StructurePowerSpawn"
|
||||
"StructureRampart" "StructureRoad" "StructureSpawn"
|
||||
"StructureStorage" "StructureTerminal" "StructureTower"
|
||||
"StructureWall"))
|
||||
|
||||
(defconst screeps-constants
|
||||
'("OK" "ERR_NOT_OWNER" "ERR_NO_PATH" "ERR_NAME_EXISTS" "ERR_BUSY"
|
||||
"ERR_NOT_FOUND" "ERR_NOT_ENOUGH_ENERGY" "ERR_NOT_ENOUGH_RESOURCES"
|
||||
"ERR_INVALID_TARGET" "ERR_FULL" "ERR_NOT_IN_RANGE"
|
||||
"ERR_INVALID_ARGS" "ERR_TIRED" "ERR_NO_BODYPART"
|
||||
"ERR_NOT_ENOUGH_EXTENSIONS" "ERR_RCL_NOT_ENOUGH"
|
||||
"ERR_GCL_NOT_ENOUGH"
|
||||
|
||||
"FIND_EXIT_TOP" "FIND_EXIT_RIGHT" "FIND_EXIT_BOTTOM"
|
||||
"FIND_EXIT_LEFT" "FIND_EXIT" "FIND_CREEPS" "FIND_MY_CREEPS"
|
||||
"FIND_HOSTILE_CREEPS" "FIND_SOURCES_ACTIVE" "FIND_SOURCES"
|
||||
"FIND_DROPPED_ENERGY" "FIND_DROPPED_RESOURCES" "FIND_STRUCTURES"
|
||||
"FIND_MY_STRUCTURES" "FIND_HOSTILE_STRUCTURES" "FIND_FLAGS"
|
||||
"FIND_CONSTRUCTION_SITES" "FIND_MY_SPAWNS" "FIND_HOSTILE_SPAWNS"
|
||||
"FIND_MY_CONSTRUCTION_SITES" "FIND_HOSTILE_CONSTRUCTION_SITES"
|
||||
"FIND_MINERALS" "FIND_NUKES"
|
||||
|
||||
"TOP" "TOP_RIGHT" "RIGHT" "BOTTOM_RIGHT" "BOTTOM" "BOTTOM_LEFT"
|
||||
"LEFT" "TOP_LEFT"
|
||||
|
||||
"COLOR_RED" "COLOR_PURPLE" "COLOR_BLUE" "COLOR_CYAN" "COLOR_GREEN"
|
||||
"COLOR_YELLOW" "COLOR_ORANGE" "COLOR_BROWN" "COLOR_GREY"
|
||||
"COLOR_WHITE"
|
||||
|
||||
"LOOK_CREEPS" "LOOK_ENERGY" "LOOK_RESOURCES" "LOOK_SOURCES"
|
||||
"LOOK_MINERALS" "LOOK_STRUCTURES" "LOOK_FLAGS"
|
||||
"LOOK_CONSTRUCTION_SITES" "LOOK_NUKES" "LOOK_TERRAIN"
|
||||
|
||||
"OBSTACLE_OBJECT_TYPES"
|
||||
|
||||
"MOVE" "WORK" "CARRY" "ATTACK" "RANGED_ATTACK" "TOUGH" "HEAL"
|
||||
"CLAIM"
|
||||
|
||||
"BODYPART_COST"
|
||||
|
||||
"CREEP_LIFE_TIME" "CREEP_CLAIM_LIFE_TIME" "CREEP_CORPSE_RATE"
|
||||
|
||||
"CARRY_CAPACITY" "HARVEST_POWER" "HARVEST_MINERAL_POWER"
|
||||
"REPAIR_POWER" "DISMANTLE_POWER" "BUILD_POWER" "ATTACK_POWER"
|
||||
"UPGRADE_CONTROLLER_POWER" "RANGED_ATTACK_POWER" "HEAL_POWER"
|
||||
"RANGED_HEAL_POWER" "REPAIR_COST" "DISMANTLE_COST"
|
||||
|
||||
"RAMPART_DECAY_AMOUNT" "RAMPART_DECAY_TIME" "RAMPART_HITS"
|
||||
"RAMPART_HITS_MAX"
|
||||
|
||||
"ENERGY_REGEN_TIME" "ENERGY_DECAY"
|
||||
|
||||
"SPAWN_HITS" "SPAWN_ENERGY_START" "SPAWN_ENERGY_CAPACITY"
|
||||
"CREEP_SPAWN_TIME"
|
||||
|
||||
"SOURCE_ENERGY_CAPACITY" "SOURCE_ENERGY_NEUTRAL_CAPACITY"
|
||||
"SOURCE_ENERGY_KEEPER_CAPACITY"
|
||||
|
||||
"WALL_HITS" "WALL_HITS_MAX"
|
||||
|
||||
"EXTENSION_HITS" "EXTENSION_ENERGY_CAPACITY"
|
||||
|
||||
"ROAD_HITS" "ROAD_WEAROUT" "ROAD_DECAY_AMOUNT" "ROAD_DECAY_TIME"
|
||||
|
||||
"LINK_HITS" "LINK_HITS_MAX" "LINK_CAPACITY" "LINK_COOLDOWN"
|
||||
"LINK_LOSS_RATIO"
|
||||
|
||||
"STORAGE_CAPACITY" "STORAGE_HITS"
|
||||
|
||||
"STRUCTURE_SPAWN" "STRUCTURE_EXTENSION" "STRUCTURE_ROAD"
|
||||
"STRUCTURE_WALL" "STRUCTURE_RAMPART" "STRUCTURE_KEEPER_LAIR"
|
||||
"STRUCTURE_PORTAL" "STRUCTURE_CONTROLLER" "STRUCTURE_LINK"
|
||||
"STRUCTURE_STORAGE" "STRUCTURE_TOWER" "STRUCTURE_OBSERVER"
|
||||
"STRUCTURE_POWER_BANK" "STRUCTURE_POWER_SPAWN" "STRUCTURE_EXTRACTOR"
|
||||
"STRUCTURE_LAB" "STRUCTURE_TERMINAL" "STRUCTURE_CONTAINER"
|
||||
"STRUCTURE_NUKER"
|
||||
|
||||
"CONSTRUCTION_COST"
|
||||
"CONSTRUCTION_COST_ROAD_SWAMP_RATIO"
|
||||
|
||||
"CONTROLLER_LEVELS" "CONTROLLER_STRUCTURES" "CONTROLLER_DOWNGRADE"
|
||||
"CONTROLLER_CLAIM_DOWNGRADE" "CONTROLLER_RESERVE"
|
||||
"CONTROLLER_RESERVE_MAX" "CONTROLLER_MAX_UPGRADE_PER_TICK"
|
||||
"CONTROLLER_ATTACK_BLOCKED_UPGRADE"
|
||||
|
||||
"TOWER_HITS" "TOWER_CAPACITY" "TOWER_ENERGY_COST"
|
||||
"TOWER_POWER_ATTACK" "TOWER_POWER_HEAL" "TOWER_POWER_REPAIR"
|
||||
"TOWER_OPTIMAL_RANGE" "TOWER_FALLOFF_RANGE" "TOWER_FALLOFF"
|
||||
|
||||
"OBSERVER_HITS" "OBSERVER_RANGE"
|
||||
|
||||
"POWER_BANK_HITS" "POWER_BANK_CAPACITY_MAX"
|
||||
"POWER_BANK_CAPACITY_MIN" "POWER_BANK_CAPACITY_CRIT"
|
||||
"POWER_BANK_DECAY" "POWER_BANK_HIT_BACK"
|
||||
|
||||
"POWER_SPAWN_HITS" "POWER_SPAWN_ENERGY_CAPACITY"
|
||||
"POWER_SPAWN_POWER_CAPACITY" "POWER_SPAWN_ENERGY_RATIO"
|
||||
|
||||
"EXTRACTOR_HITS"
|
||||
|
||||
"LAB_HITS" "LAB_MINERAL_CAPACITY"
|
||||
"LAB_ENERGY_CAPACITY" "LAB_BOOST_ENERGY" "LAB_BOOST_MINERAL"
|
||||
"LAB_COOLDOWN"
|
||||
|
||||
"GCL_POW" "GCL_MULTIPLY" "GCL_NOVICE"
|
||||
|
||||
"MODE_SIMULATION" "MODE_SURVIVAL" "MODE_WORLD" "MODE_ARENA"
|
||||
|
||||
"TERRAIN_MASK_WALL" "TERRAIN_MASK_SWAMP" "TERRAIN_MASK_LAVA"
|
||||
|
||||
"MAX_CONSTRUCTION_SITES" "MAX_CREEP_SIZE"
|
||||
|
||||
"MINERAL_REGEN_TIME" "MINERAL_MIN_AMOUNT" "MINERAL_RANDOM_FACTOR"
|
||||
|
||||
"TERMINAL_CAPACITY" "TERMINAL_HITS" "TERMINAL_SEND_COST"
|
||||
"TERMINAL_MIN_SEND"
|
||||
|
||||
"CONTAINER_HITS" "CONTAINER_CAPACITY" "CONTAINER_DECAY"
|
||||
"CONTAINER_DECAY_TIME" "CONTAINER_DECAY_TIME_OWNED"
|
||||
|
||||
"NUKER_HITS" "NUKER_COOLDOWN" "NUKER_ENERGY_CAPACITY"
|
||||
"NUKER_GHODIUM_CAPACITY" "NUKE_LAND_TIME" "NUKE_RANGE" "NUKE_DAMAGE"
|
||||
|
||||
"RESOURCE_ENERGY" "RESOURCE_POWER"
|
||||
|
||||
"RESOURCE_HYDROGEN" "RESOURCE_OXYGEN" "RESOURCE_UTRIUM"
|
||||
"RESOURCE_LEMERGIUM" "RESOURCE_KEANIUM" "RESOURCE_ZYNTHIUM"
|
||||
"RESOURCE_CATALYST" "RESOURCE_GHODIUM"
|
||||
|
||||
"RESOURCE_HYDROXIDE" "RESOURCE_ZYNTHIUM_KEANITE"
|
||||
"RESOURCE_UTRIUM_LEMERGITE"
|
||||
|
||||
"RESOURCE_UTRIUM_HYDRIDE" "RESOURCE_UTRIUM_OXIDE"
|
||||
"RESOURCE_KEANIUM_HYDRIDE" "RESOURCE_KEANIUM_OXIDE"
|
||||
"RESOURCE_LEMERGIUM_HYDRIDE" "RESOURCE_LEMERGIUM_OXIDE"
|
||||
"RESOURCE_ZYNTHIUM_HYDRIDE" "RESOURCE_ZYNTHIUM_OXIDE"
|
||||
"RESOURCE_GHODIUM_HYDRIDE" "RESOURCE_GHODIUM_OXIDE"
|
||||
|
||||
"RESOURCE_UTRIUM_ACID" "RESOURCE_UTRIUM_ALKALIDE"
|
||||
"RESOURCE_KEANIUM_ACID" "RESOURCE_KEANIUM_ALKALIDE"
|
||||
"RESOURCE_LEMERGIUM_ACID" "RESOURCE_LEMERGIUM_ALKALIDE"
|
||||
"RESOURCE_ZYNTHIUM_ACID" "RESOURCE_ZYNTHIUM_ALKALIDE"
|
||||
"RESOURCE_GHODIUM_ACID" "RESOURCE_GHODIUM_ALKALIDE"
|
||||
|
||||
"RESOURCE_CATALYZED_UTRIUM_ACID"
|
||||
"RESOURCE_CATALYZED_UTRIUM_ALKALIDE"
|
||||
"RESOURCE_CATALYZED_KEANIUM_ACID"
|
||||
"RESOURCE_CATALYZED_KEANIUM_ALKALIDE"
|
||||
"RESOURCE_CATALYZED_LEMERGIUM_ACID"
|
||||
"RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE"
|
||||
"RESOURCE_CATALYZED_ZYNTHIUM_ACID"
|
||||
"RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE"
|
||||
"RESOURCE_CATALYZED_GHODIUM_ACID"
|
||||
"RESOURCE_CATALYZED_GHODIUM_ALKALIDE"
|
||||
|
||||
"REACTIONS" "BODYPARTS_ALL" "RESOURCES_ALL" "COLORS_ALL"))
|
||||
|
||||
(def-project-type! screeps "screeps"
|
||||
:match "/screeps/.+$"
|
||||
:modes (nodejs-project-mode))
|
||||
|
||||
(add-hook! screeps-project-mode
|
||||
(when (eq major-mode 'js2-mode)
|
||||
(add-to-list 'flycheck-disabled-checkers 'javascript-jshint)
|
||||
(setq js2-additional-externs (append '("_") screeps-objects screeps-constants))))
|
||||
|
||||
(provide 'custom-screeps)
|
||||
;;; custom-screeps.el ends here
|
169
modules/lang/javascript/config.el
Normal file
169
modules/lang/javascript/config.el
Normal file
|
@ -0,0 +1,169 @@
|
|||
;;; module-js.el
|
||||
|
||||
(use-package unityjs-mode
|
||||
:mode "/Assets/.*\\.js$"
|
||||
:config (add-hook 'unityjs-mode-hook 'flycheck-mode))
|
||||
|
||||
(use-package js2-mode
|
||||
:mode "\\.js$"
|
||||
:interpreter "node"
|
||||
:init (add-hook! js2-mode '(tern-mode flycheck-mode))
|
||||
:config
|
||||
(def-repl! js2-mode nodejs-repl)
|
||||
(def-company-backend! js2-mode (tern))
|
||||
(def-docset! js2-mode "js,jquery,nodejs,angularjs,express")
|
||||
(def-electric! js2-mode :chars (?\} ?\) ?.) :words ("||" "&&"))
|
||||
(setq-default
|
||||
js2-skip-preprocessor-directives t
|
||||
js2-highlight-external-variables nil
|
||||
js2-mode-show-parse-errors nil)
|
||||
|
||||
(add-hook! lb6-project-mode
|
||||
(when (eq major-mode 'js2-mode)
|
||||
(setq js2-additional-externs '("LaunchBar" "File" "Action" "HTTP" "include" "Lib"))))
|
||||
|
||||
;; [pedantry intensifies]
|
||||
(add-hook! js2-mode (setq mode-name "JS2"
|
||||
js-switch-indent-offset js-indent-level))
|
||||
|
||||
(map! :map js2-mode-map (:localleader :nv ";" 'doom/append-semicolon)))
|
||||
|
||||
(use-package tern
|
||||
:after js2-mode
|
||||
:commands (tern-mode))
|
||||
|
||||
(use-package company-tern
|
||||
:after tern)
|
||||
|
||||
(use-package js2-refactor
|
||||
:after js2-mode
|
||||
:config
|
||||
(mapc (lambda (x)
|
||||
(let ((command-name (car x))
|
||||
(title (cadr x))
|
||||
(region-p (caddr x))
|
||||
predicate)
|
||||
(setq predicate (cond ((eq region-p 'both) nil)
|
||||
(t (if region-p
|
||||
(lambda () (use-region-p))
|
||||
(lambda () (not (use-region-p)))))))
|
||||
(emr-declare-command
|
||||
(intern (format "js2r-%s" (symbol-name command-name)))
|
||||
:title title :modes 'js2-mode :predicate predicate)))
|
||||
'((extract-function "extract function" t)
|
||||
(extract-method "extract method" t)
|
||||
(introduce-parameter "introduce parameter" t)
|
||||
(localize-parameter "localize parameter" nil)
|
||||
(expand-object "expand object" nil)
|
||||
(contract-object "contract object" nil)
|
||||
(expand-function "expand function" nil)
|
||||
(contract-function "contract function" nil)
|
||||
(expand-array "expand array" nil)
|
||||
(contract-array "contract array" nil)
|
||||
(wrap-buffer-in-iife "wrap buffer in ii function" nil)
|
||||
(inject-global-in-iife "inject global in ii function" t)
|
||||
(add-to-globals-annotation "add to globals annotation" nil)
|
||||
(extract-var "extract variable" t)
|
||||
(inline-var "inline variable" t)
|
||||
(rename-var "rename variable" nil)
|
||||
(var-to-this "var to this" nil)
|
||||
(arguments-to-object "arguments to object" nil)
|
||||
(ternary-to-if "ternary to if" nil)
|
||||
(split-var-declaration "split var declaration" nil)
|
||||
(split-string "split string" nil)
|
||||
(unwrap "unwrap" t)
|
||||
(log-this "log this" 'both)
|
||||
(debug-this "debug this" 'both)
|
||||
(forward-slurp "forward slurp" nil)
|
||||
(forward-barf "forward barf" nil))))
|
||||
|
||||
(use-package nodejs-repl :commands (nodejs-repl))
|
||||
|
||||
;;
|
||||
(use-package jsx-mode :mode "\\.jsx$")
|
||||
|
||||
(use-package coffee-mode
|
||||
:mode "\\.coffee$"
|
||||
:config (setq-default coffee-indent-like-python-mode t))
|
||||
|
||||
(use-package typescript-mode
|
||||
:mode "\\.ts$"
|
||||
:init
|
||||
(add-hook! typescript-mode
|
||||
'(rainbow-delimiters-mode doom|ts-fontify)))
|
||||
|
||||
(use-package tide
|
||||
:after typescript-mode
|
||||
:config
|
||||
(setq tide-format-options
|
||||
'(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t
|
||||
:placeOpenBraceOnNewLineForFunctions nil))
|
||||
|
||||
(defun doom|tide-setup ()
|
||||
(tide-setup)
|
||||
(flycheck-mode +1)
|
||||
(eldoc-mode +1))
|
||||
(add-hook 'typescript-mode-hook 'doom|tide-setup)
|
||||
|
||||
(add-hook! web-mode
|
||||
(when (f-ext? buffer-file-name "tsx")
|
||||
(doom|tide-setup)))
|
||||
|
||||
(map! :map typescript-mode-map
|
||||
:m "gd" 'tide-jump-to-definition
|
||||
(:leader :n "h" 'tide-documentation-at-point))
|
||||
|
||||
(advice-add 'tide-project-root :override 'doom/project-root))
|
||||
|
||||
;;
|
||||
(defvar npm-conf (make-hash-table :test 'equal))
|
||||
(def-project-type! nodejs "node"
|
||||
:modes (web-mode js-mode coffee-mode css-mode sass-mode pug-mode)
|
||||
:files ("package.json")
|
||||
:when
|
||||
(lambda (&rest _)
|
||||
(let* ((project-path (doom/project-root))
|
||||
(hash (gethash project-path npm-conf))
|
||||
(package-file (f-expand "package.json" project-path))
|
||||
deps)
|
||||
(awhen (and (not hash) (f-exists? package-file)
|
||||
(ignore-errors (json-read-file package-file)))
|
||||
(puthash project-path it npm-conf)))
|
||||
t))
|
||||
|
||||
(def-project-type! expressjs "express"
|
||||
:modes (nodejs-project-mode bower-project-mode)
|
||||
:when
|
||||
(lambda (&rest _)
|
||||
(awhen (gethash (doom/project-root) npm-conf)
|
||||
(assq 'express (cdr-safe (assq 'dependencies it))))))
|
||||
|
||||
;; TODO electron-compile support
|
||||
(def-project-type! electron "electron"
|
||||
:modes (nodejs-project-mode)
|
||||
:files ("app/index.html" "app/main.js")
|
||||
:when
|
||||
(lambda (&rest _)
|
||||
(awhen (gethash (doom/project-root) npm-conf)
|
||||
(let ((deps (append (car-safe (assq 'dependencies it))
|
||||
(car-safe (assq 'devDependencies it)))))
|
||||
(or (assq 'electron-prebuilt deps)
|
||||
(assq 'electron-packager deps)
|
||||
(string-prefix-p "electron" (or (assq 'start it) "") t))))))
|
||||
|
||||
(def-project-type! reactjs "react"
|
||||
:modes (nodejs-project-mode bower-project-mode)
|
||||
:when
|
||||
(lambda (&rest _)
|
||||
(let* ((project (doom/project-root))
|
||||
(deps (append (cdr-safe (assq 'dependencies (gethash project bower-conf)))
|
||||
(cdr-safe (assq 'dependencies (gethash project npm-conf))))))
|
||||
(assq 'react deps))))
|
||||
|
||||
(def-project-type! gulpjs "gulp"
|
||||
:modes (nodejs-project-mode)
|
||||
:files ("gulpfile.js")
|
||||
:build ("gulp %s" "gulpfile.js"))
|
||||
|
||||
(provide 'module-js)
|
||||
;;; module-js.el ends here
|
Loading…
Add table
Add a link
Reference in a new issue