From acaa222aa09d895001a181b407ebca1100a3ed63 Mon Sep 17 00:00:00 2001 From: gacallea Date: Mon, 4 Dec 2023 14:34:05 +0100 Subject: [PATCH 1/3] feat(swift): mv to swift only support (no xcode tooling here) --- lua/astrocommunity/pack/swift/README.md | 51 +++++++++++-------------- lua/astrocommunity/pack/swift/init.lua | 22 +---------- 2 files changed, 25 insertions(+), 48 deletions(-) diff --git a/lua/astrocommunity/pack/swift/README.md b/lua/astrocommunity/pack/swift/README.md index b7ba5a360..83cb9541a 100644 --- a/lua/astrocommunity/pack/swift/README.md +++ b/lua/astrocommunity/pack/swift/README.md @@ -1,38 +1,33 @@ # 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 -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 = "rb", -- Set to 0 to disable - run_picker = "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 = "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). diff --git a/lua/astrocommunity/pack/swift/init.lua b/lua/astrocommunity/pack/swift/init.lua index 76e1794dc..b40889131 100644 --- a/lua/astrocommunity/pack/swift/init.lua +++ b/lua/astrocommunity/pack/swift/init.lua @@ -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) @@ -26,9 +9,8 @@ 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, }, } From 537e11598fb0a3974099fedcae098d07b26ee895 Mon Sep 17 00:00:00 2001 From: Uzair Aftab Date: Tue, 5 Dec 2023 14:59:10 +0100 Subject: [PATCH 2/3] feat(swift): Add back codelldb --- lua/astrocommunity/pack/swift/init.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/astrocommunity/pack/swift/init.lua b/lua/astrocommunity/pack/swift/init.lua index b40889131..591d5fbc9 100644 --- a/lua/astrocommunity/pack/swift/init.lua +++ b/lua/astrocommunity/pack/swift/init.lua @@ -9,6 +9,10 @@ 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, From 06d1565ababfc93624646b657dcc561c49bc3963 Mon Sep 17 00:00:00 2001 From: Uzair Aftab Date: Tue, 5 Dec 2023 15:04:08 +0100 Subject: [PATCH 3/3] docs(swift): Add note about codelldb in docs --- lua/astrocommunity/pack/swift/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/astrocommunity/pack/swift/README.md b/lua/astrocommunity/pack/swift/README.md index 83cb9541a..661603fa6 100644 --- a/lua/astrocommunity/pack/swift/README.md +++ b/lua/astrocommunity/pack/swift/README.md @@ -9,6 +9,7 @@ This plugin pack does the following: - Adds `swift` Treesitter parsers - Adds `sourcekit` in LSP servers - Adds `sourcekit` in LSP config +- Adds `codelldb` for debugging ## SwiftLint and SwiftFormat