From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#65672: [PATCH emacs 1/1] Add lua-ts-mode Date: Sat, 02 Sep 2023 16:10:06 +0200 Message-ID: <875y4sd5tt.fsf@gmail.com> References: <169352253839.28940.16024479871485106701-0@git.sr.ht> <169352253839.28940.16024479871485106701-1@git.sr.ht> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26015"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: ~johnmuhl , ~emacs/emacs-devel@lists.sr.ht, 65672@debbugs.gnu.org To: ~johnmuhl Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 02 16:11:06 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qcRL7-0006Zl-MV for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 Sep 2023 16:11:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcRKz-0003BQ-Hk; Sat, 02 Sep 2023 10:10:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcRKw-0003BB-35 for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2023 10:10:54 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcRKu-0004Rx-LQ for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2023 10:10:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qcRL4-0000k2-D9 for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2023 10:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Sep 2023 14:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65672 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65672-submit@debbugs.gnu.org id=B65672.16936638282809 (code B ref 65672); Sat, 02 Sep 2023 14:11:02 +0000 Original-Received: (at 65672) by debbugs.gnu.org; 2 Sep 2023 14:10:28 +0000 Original-Received: from localhost ([127.0.0.1]:38215 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcRKV-0000jF-Iw for submit@debbugs.gnu.org; Sat, 02 Sep 2023 10:10:27 -0400 Original-Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:58723) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcRKT-0000iw-4D for 65672@debbugs.gnu.org; Sat, 02 Sep 2023 10:10:26 -0400 Original-Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-52c74a2e8edso1254764a12.1 for <65672@debbugs.gnu.org>; Sat, 02 Sep 2023 07:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693663809; x=1694268609; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=31Ohlf24naWgLg9CIom31egp/3C2s4hX4yBEIQ0JyVw=; b=kUYo3sZ02z3zdpq1MWB2wQ98pHvNd5lD77fYtWJEz9hcaESUjPbhh5Og4cqboePxtJ wPLJxEhBfNUGm+0D35D75QW1EF3to2qYXz+jITsoRhIZNvRJfd3azSQF3H4pIoOQ/6wI a+r7dc8Rt/JZvNi/4hIkHcJdtj/xAzt+GylYRbehBo4lAC60UgQ7WAzfsdFsIdHzYfd0 8jW80xRGHalWs17wcc/vvACedrUpKhOXimapzETBnZpZs5feMb94pHNgHQBZeszdDzVG d/mGAp5t496lVYo7z8MFF2i2D37HmYrY7XnumLeKdzo6aGutcy/mSr5izrPjvLCfYM6D FmcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693663809; x=1694268609; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=31Ohlf24naWgLg9CIom31egp/3C2s4hX4yBEIQ0JyVw=; b=lQXISylzhshQ0Do+hIzrmwPiHjOCNqwr5hz773vmsxtulQpbHiKbZpvrGWx+9EPq4K f0Fnx3HNMvEj1oHLGszPi4dYgl4YxmG82fgmHLPP7p9pmBPugGsKyH1tWv8k5TAZCII1 AwbHptTNrjiWvNYP1hcKcq3W4JfKe3jeigeKWJN1RP81oel9tAFujJteHaqy8cSGdNWZ z2vwtkPkgI5bpZCRfj2zQcSqzp6y/RYakJEMUei3MYLzJSFzYgpAJJvIaRyv1vhEw47/ iEXcRj8gQp4KTjNUstDTY6LwZqNOZ6M0plnVfgRSsMf9rlx/tAGn21afTRT07gYLB/wN 3W4A== X-Gm-Message-State: AOJu0Yy3q54FH/w3DNLgxZ38e8NREzGujfgAWNYIOgIf0DlkmxjUYixg wBsz9DpIkn5Oy/yP2mpUYUfRL6pbs7I= X-Google-Smtp-Source: AGHT+IE0+LU2ZiRi/8J6PNkDbmt43NFwrlreTbKvaFa5zj72vClEBJ+MyyfoEq4aWNN9v5gokhfCeA== X-Received: by 2002:aa7:c645:0:b0:51e:4439:f474 with SMTP id z5-20020aa7c645000000b0051e4439f474mr3586205edr.35.1693663809074; Sat, 02 Sep 2023 07:10:09 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:6098::d81]) by smtp.gmail.com with ESMTPSA id d3-20020aa7d5c3000000b005232ea6a330sm3461438eds.2.2023.09.02.07.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 07:10:08 -0700 (PDT) In-Reply-To: <169352253839.28940.16024479871485106701-1@git.sr.ht> (johnmuhl@git.sr.ht's message of "Thu, 31 Aug 2023 16:32:06 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:269002 Archived-At: On Thu, 31 Aug 2023 at 16:32, ~johnmuhl wrote: > +(defcustom inferior-lua-switches "-i" > + "Command line options for the inferior Lua process." > + :type 'string > + :safe 'stringp > + :group 'lua > + :version "30.1") This should be given as a list of strings rather a string that you later need to call split-string-shell-command on. Also, I think it's probably best to use the same lua-ts- prefix for the Lua shell variables and command. If you're really fond of a `inferior-lua' or `run-lua' command, it could be an alias (but then one might need to think about what to do about name clashes when one of the other Lua modes is installed). > +(defcustom inferior-lua-startfile "" > + "File to load into the inferior Lua process at startup." > + :type 'string > + :safe 'stringp > + :group 'lua > + :version "30.1") This should be nil by default. > +(defun lua-ts-documentation-at-point () > + "Show documentation of function at point in Lua manual." > + (interactive) > + (unless (string-blank-p lua-ts-lua-manual) > + (let ((character-before (char-to-string (char-before))) > + id) > + (save-excursion > + ;; When point is mid-word `treesit-thing-at-point' > + ;; may return the parent node of the thing at point. > + (unless (or (bolp) > + (not (string-match-p "[[:alnum:]]" character-before))) > + (backward-word)) > + (let ((node (treesit-thing-at-point 'builtin nil))) > + (setq id (pcase (treesit-node-type node) > + ("dot_index_expression" (treesit-node-text node t)) > + ("function_call" > + (let* ((child (treesit-node-child-by-field-name node "name")) > + (name (treesit-node-text child t))) > + (if (string-match-p ":" name) > + (replace-regexp-in-string "^.*:" "file:" name) > + name))))))) > + (when id (browse-url (concat lua-ts-lua-manual "#pdf-" id)))))) I wouldn't add this command. It's not polished enough and too ad-hoc in the sense that this functionality is (or should be) covered by other mechanisms: Info, Eldoc, etc. > + ;; Outline. > + (setq-local outline-regexp > + (rx (or "--[[" "do" "for" "if" "repeat" "while" > + (seq (** 0 1 "local ") "function")))) What is the idea behind "--[["? Should one allow whitespace in front of these strings (also inferring the outline level from that)? Also, one should allow arbitrary whitespace after "local" (I'd say "local\\s-+") and enclose the keywords with "\\_<...\\_>". In general, this looks nice, thanks!