<p></p>
<p><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/elextr/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/elextr">@elextr</a> I think, all <code>SCI_*LEXER*</code> are not really needed in this plugin (so they can stay in this list and no more), also you wrote</p>
<blockquote>
<p>You should not set the lexer directly, set the Geany filetype instead.</p>
</blockquote>
<p><a href="https://github.com/geany/geany-plugins/issues/646" data-hovercard-type="issue" data-hovercard-url="/geany/geany-plugins/issues/646/hovercard">here</a>. Now we can get the current filetype</p>
<div class="highlight highlight-source-lua"><pre><span class="pl-k">local</span> finfo <span class="pl-k">=</span> geany.<span class="pl-c1">fileinfo</span>()
<span class="pl-k">if</span> finfo <span class="pl-k">~=</span> <span class="pl-c1">nil</span> <span class="pl-k">then</span>
  geany.<span class="pl-c1">message</span>(<span class="pl-s"><span class="pl-pds">'</span>Current filetype is "<span class="pl-pds">'</span></span> <span class="pl-k">..</span> finfo.<span class="pl-smi">type</span> <span class="pl-k">..</span> <span class="pl-s"><span class="pl-pds">'</span>": <span class="pl-pds">'</span></span> <span class="pl-k">..</span> finfo.<span class="pl-smi">desc</span>)
<span class="pl-k">end</span></pre></div>
<p>and it may be useful to change the current filetype: something like <code>geany.settype(".cmake")</code> with</p>
<div class="highlight highlight-source-c"><pre><span class="pl-c"><span class="pl-c">/*</span> Change the current file type by the specified file extension <span class="pl-c">*/</span></span>
<span class="pl-k">static</span> gint <span class="pl-en">glspi_set_filetype</span>(lua_State* L)
{
        GeanyDocument *doc=<span class="pl-c1">NULL</span>;
        GeanyFiletype *ft=<span class="pl-c1">NULL</span>;
        <span class="pl-k">const</span> gchar *ftn=<span class="pl-c1">NULL</span>;

        <span class="pl-k">if</span> (<span class="pl-c1">lua_gettop</span>(L)==<span class="pl-c1">1</span>){
                <span class="pl-k">if</span> (!<span class="pl-c1">lua_isstring</span>(L, <span class="pl-c1">1</span>)) { <span class="pl-k">return</span> <span class="pl-c1">FAIL_STRING_ARG</span>(<span class="pl-c1">1</span>); }
                doc = <span class="pl-c1">document_get_current</span>();
                <span class="pl-k">if</span> (!(doc && doc-><span class="pl-smi">is_valid</span>)) { <span class="pl-k">return</span> <span class="pl-c1">0</span>; }
                ftn=<span class="pl-c1">lua_tostring</span>(L, <span class="pl-c1">1</span>);
                <span class="pl-k">if</span> (<span class="pl-s"><span class="pl-pds">'</span><span class="pl-cce">\0</span><span class="pl-pds">'</span></span> == ftn[<span class="pl-c1">0</span>]) { <span class="pl-k">return</span> <span class="pl-c1">0</span>; }
                ft=<span class="pl-c1">filetypes_detect_from_extension</span>(ftn);
                <span class="pl-k">if</span> (ft != <span class="pl-c1">NULL</span>){
                        <span class="pl-c1">document_set_filetype</span>(doc, ft);
                        <span class="pl-k">return</span> <span class="pl-c1">1</span>;
                }
        }
        <span class="pl-k">return</span> <span class="pl-c1">0</span>;
}</pre></div>
<p>in <code>glspi_doc.c</code>. But currently <code>filetypes_detect_from_extension</code> is not a prt of Geany API.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany-plugins/pull/1123#issuecomment-949600361">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJ5ZZJWI3XI4XTQAOZLUIFMS3ANCNFSM5GKFLYSA">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/AAIOWJ7TB7MZYVT3TLWX2ZTUIFMS3A5CNFSM5GKFLYSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHCM4A2I.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany-plugins/pull/1123#issuecomment-949600361",
"url": "https://github.com/geany/geany-plugins/pull/1123#issuecomment-949600361",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>