Skip to content

FreemapSlovakia/osm2pgsql-lua-definitions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

osm2pgsql flex config Lua definitions for LuaLS

Lua type definitions for osm2pgsql flex config designed for the Lua Language Server. This provides completion, hover docs, and diagnostics for the osm2pgsql Lua API when writing style scripts.

What's included

  • library/osm2pgsql.lua type annotations for the public osm2pgsql Lua API.
  • config.json LuaLS addon config to register the osm2pgsql global.

Install

Clone the repo and point LuaLS at it.

Option A: use the addon config (recommended).

{
  "Lua.workspace.userThirdParty": ["/path/to/osm2pgsql-lua-definitions"]
}

Option B: add the library folder directly.

{
  "Lua.workspace.library": ["/path/to/osm2pgsql-lua-definitions/library"]
}

Restart the language server after updating settings.

Example

local roads = osm2pgsql.define_table({
  name = "roads",
  ids = { type = "way", id_column = "osm_id" },
  columns = {
    { column = "name", type = "text" },
    { column = "geom", type = "linestring" },
  },
})

function osm2pgsql.process_way(object)
  if object.tags.highway then
    roads:insert({
      name = object.tags.name,
      geom = object:as_linestring(),
    })
  end
end

License

MIT. See LICENSE.

About

Lua type definitions for osm2pgsql designed for the Lua Language Server

Topics

Resources

License

Stars

Watchers

Forks

Languages