Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(swift): mv to swift only support (no xcode tooling here) #670

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 24 additions & 28 deletions lua/astrocommunity/pack/swift/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
# Swift Language Pack

## Note
Requires:

xbase is a WIP plugin, and the experience provided by this plugin might be
lackluster.
- [sourcekit-lsp](https://github.com/apple/sourcekit-lsp)

## Requirements
This plugin pack does the following:

1. Make sure you have [sourcekit-lsp](https://github.com/apple/sourcekit-lsp)
installed on your machine.
- Adds `swift` Treesitter parsers
- Adds `sourcekit` in LSP servers
- Adds `sourcekit` in LSP config
- Adds `codelldb` for debugging

2. Install Xcode Device Simulators: To enable simulator functionality from
within Neovim, you need to have Xcode Device Simulators installed on your
machine. You can install these simulators from Xcode.
## SwiftLint and SwiftFormat

3. Mappings: The default mappings for the xbase plugin overlap with AstroNvim's
default. Therefore, you should set the mappings yourself. Refer to
[xBase](https://github.com/kkharji/xbase#neovim-3) documentation for more
options.
When it comes to linting and formatting, Swift is not standardized yet. Thus,
you need to set your favorite configuration in `user/null-ls.lua`. For example:

```lua
opts = {
-- ... (other options)

mappings = {
enable = true,
build_picker = "<leader>rb", -- Set to 0 to disable
run_picker = "<leader>ra", -- Set to 0 to disable
watch_picker = 0, -- Set to 0 to disable
all_picker = 0, -- Set to 0 to disable
toggle_split_log_buffer = 0,
toggle_vsplit_log_buffer = "<leader>rs",
},

-- ... (other options)
}
[...]
config.sources = {
-- Set a formatter
null_ls.builtins.formatting.swiftformat, -- https://github.com/nicklockwood/SwiftFormat
-- null_ls.builtins.formatting.swift_format, -- https://github.com/apple/swift-format

-- Set a linter
null_ls.builtins.diagnostics.swiftlint,
}
[...]
```

Make sure to install [SwiftLint](https://github.com/realm/SwiftLint) and either
one of [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) **OR** [Apple's
Swift-Format](https://github.com/apple/swift-format).
22 changes: 4 additions & 18 deletions lua/astrocommunity/pack/swift/init.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
local utils = require "astronvim.utils"

return {
{
"xbase-lab/xbase",
ft = {
"swift",
"objcpp",
"objc",
},
run = "make install", -- or "make install && make free_space" (not recommended, longer build time)
dependencies = {
"neovim/nvim-lspconfig",
-- "nvim-telescope/telescope.nvim", -- optional
-- "nvim-lua/plenary.nvim", -- optional/requirement of telescope.nvim
-- "stevearc/dressing.nvim", -- optional (in case you don't use telescope but something else)
},
init = function() require("astronvim.utils.lsp").setup "sourcekit" end,
},

{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
Expand All @@ -26,9 +9,12 @@ return {
end
end,
},

{
"jay-babu/mason-nvim-dap.nvim",
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "codelldb") end,
},
{
"williamboman/mason-lspconfig.nvim",
init = function() require("astronvim.utils.lsp").setup "sourcekit" end,
},
}