question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IntelliJ and Hammerspoon files

See original GitHub issue

Environment

Name Version
IDEA version Build #IU-222.3244.4, built on June 29, 2022
Luanalysis version 1.2.2-IDEA203
OS macOS M1 Monterey 12.1 (21C52)

Preferences

Preferences -> Languages & Frameworks > Luanalysis: Bildschirmfoto 2022-07-05 um 06 40 16

Lua

Name Setting
Language level Lua 5.3

Type Safety

Name Setting
Strict nil checks
Unknown type (any) is indexable ☑️
Unknown type (any) is callabale ☑️

What are the steps to reproduce this issue?

i tried to use IntelliJ IDEA to edit the hammerspoon lua files

What happens?

one problem is, that it marks me some of the hs. as unknown variables and also some more errors because of unknown types

this also show me an error:

  local win = hs.window.focusedWindow()
  local app = win:application()
  local currentFrame = win:frame()
  local wins = app:allWindows()
  for _, childwin in ipairs(wins) do
    childwin:setFrame(currentFrame) -- No such member 'setFrame' found on type 'V'
  end
local function Set (list)
  local set = {}
  for _, l in ipairs(list) do set[l] = true end -- error: No such indexer '[V]' found on type 'table'
  return set
end

What were you expecting to happen?

  • no errors
  • a way to include the hammerspoon source files

Any logs, error output, etc?

  • No such member 'setFrame' found on type 'V'
  • No such indexer '[V]' found on type 'table'

Any other comments?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Benjamin-Dobellcommented, Jul 5, 2022

Luanalysis is fairly opinionated. You can certainly turn inspections off but you’ll lose out on the type safety benefits. In this case you probably want something like:

---@generic V
---@param list V[]
local function Set (list)
    ---@type table<V, nil | true>
    local set = {}
    for _, l in ipairs(list) do set[l] = true end
    return set
end
0reactions
mueschacommented, Nov 23, 2022

the creator of EmmyLua explained why he not direct use the files in App folder - but maybe there is an other idea how to get it working 😃

Why not just add /Applications/Hammerspoon.app/Contents/Resources/extensions/ as an external library to the lsp config?

Simply adding the hammerspoon extensions directory as an external library doesn’t work for a couple of reasons:

class instances, constructors and function return would not get proper autocompletion _coresetup populates the hs[string] table with all modules. LSP servers have a hard time dealing with this and think all functions/methods/variables anywhere are valid auto completions for every module. With the generated stubs, auto completion works for all HS functionality.

Source: https://github.com/Hammerspoon/hammerspoon/pull/2530#issue-710269254

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · Benjamin-Dobell/IntelliJ-Luanalysis - GitHub
Contribute to Benjamin-Dobell/IntelliJ-Luanalysis development by creating an account on GitHub. ... IntelliJ and Hammerspoon files.
Read more >
Hammerspoon vs IntelliJ IDEA detailed comparison as of 2022 - Slant
When comparing Hammerspoon vs IntelliJ IDEA, the Slant community recommends IntelliJ IDEA for most people. In the question "What are the best power...
Read more >
docs » hs.application - Hammerspoon
... provided are defined in the Carbon framework headers in the Menus.h file, ... of the application on disk, e.g. "IntelliJ IDEA", rather...
Read more >
Creating a productive osx environment - Hammerspoon
This post will introduce hammerspoon, an automation framework for macOS. If you are interested in more osx productivity blog posts, ...
Read more >
My Personal Mac Productivity Setup | by Alfian Dhimas - Medium
Let's make the configuration file in ~/.hammerspoon/init.lua. First thing first, let's add our ... That made me decided to move to IntelliJ by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found