From c8d4ea3cd1e18e0831a6f74d7edcd5c08545618a Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Fri, 17 Apr 2026 14:33:42 +0200 Subject: [PATCH] Seperate flutter and lsp but has log color issue --- .nvimlog | 6 ++ lazy-lock.json | 27 ++++----- lua/plugins/flutter.lua | 121 ++++++++++++++++++++++++++++++++++++++++ lua/plugins/lsp.lua | 72 ++++++++---------------- 4 files changed, 164 insertions(+), 62 deletions(-) create mode 100644 lua/plugins/flutter.lua diff --git a/.nvimlog b/.nvimlog index e69de29..95e362e 100644 --- a/.nvimlog +++ b/.nvimlog @@ -0,0 +1,6 @@ +WRN 2026-04-17T11:59:07.367 ?.87100 server_start:199: Failed to start server: operation not permitted: /var/folders/2m/swywvgx56d3605sg4w8sngww0000gn/T/nvim.yaso_meth/KxW1Fr/nvim.87100.0 +WRN 2026-04-17T11:59:11.612 ?.87111 server_start:199: Failed to start server: operation not permitted: /var/folders/2m/swywvgx56d3605sg4w8sngww0000gn/T/nvim.yaso_meth/JWMbgP/nvim.87111.0 +WRN 2026-04-17T11:59:19.290 ?.87136 server_start:199: Failed to start server: operation not permitted: /var/folders/2m/swywvgx56d3605sg4w8sngww0000gn/T/nvim.yaso_meth/OzOmzX/nvim.87136.0 +WRN 2026-04-17T12:02:53.603 ?.88346 server_start:199: Failed to start server: operation not permitted: /var/folders/2m/swywvgx56d3605sg4w8sngww0000gn/T/nvim.yaso_meth/svFBSD/nvim.88346.0 +WRN 2026-04-17T12:12:45.385 ?.90272 server_start:199: Failed to start server: operation not permitted: /var/folders/2m/swywvgx56d3605sg4w8sngww0000gn/T/nvim.yaso_meth/Jd4YdQ/nvim.90272.0 +WRN 2026-04-17T12:31:44.853 ?.5405 server_start:199: Failed to start server: operation not permitted: /var/folders/2m/swywvgx56d3605sg4w8sngww0000gn/T/nvim.yaso_meth/FFDhfK/nvim.5405.0 diff --git a/lazy-lock.json b/lazy-lock.json index 7fa7349..57d6840 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,27 +1,28 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" }, + "LuaSnip": { "branch": "master", "commit": "a62e1083a3cfe8b6b206e7d3d33a51091df25357" }, + "baleia.nvim": { "branch": "main", "commit": "32617940adb2eea56e85a64883a19961ceac9641" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "dashboard-nvim": { "branch": "master", "commit": "0775e567b6c0be96d01a61795f7b64c1758262f6" }, + "dashboard-nvim": { "branch": "master", "commit": "f787e3462c2ee2b6117b17c1aa4ddf66cb6f57fe" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "flutter-tools.nvim": { "branch": "main", "commit": "677cc07c16e8b89999108d2ebeefcfc5f539b73c" }, "harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" }, - "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, - "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "a979821a975897b88493843301950c456a725982" }, - "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lualine.nvim": { "branch": "master", "commit": "a905eeebc4e63fdc48b5135d3bf8aea5618fb21c" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0a3b42c3e503df87aef6d6513e13148381495c3a" }, + "mason.nvim": { "branch": "main", "commit": "b03fb0f20bc1d43daf558cda981a2be22e73ac42" }, "mini.ai": { "branch": "main", "commit": "bfb26d9072670c3aaefab0f53024b2f3729c8083" }, "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, - "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, - "nvim-lspconfig": { "branch": "master", "commit": "841c6d4139aedb8a3f2baf30cef5327371385b93" }, - "nvim-treesitter": { "branch": "main", "commit": "53f6ce29df5841ce26e5a9f06fb371088b8d8031" }, - "nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" }, - "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, + "nvim-lspconfig": { "branch": "master", "commit": "4b7fbaa239c5db6b36f424a4521ca9f1a401be33" }, + "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, + "nvim-web-devicons": { "branch": "master", "commit": "c72328a5494b4502947a022fe69c0c47e53b6aa6" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, - "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, - "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, + "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }, + "tokyonight.nvim": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" }, "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" } } diff --git a/lua/plugins/flutter.lua b/lua/plugins/flutter.lua new file mode 100644 index 0000000..e5c0d9b --- /dev/null +++ b/lua/plugins/flutter.lua @@ -0,0 +1,121 @@ +return { + { + "nvim-flutter/flutter-tools.nvim", + lazy = false, + dependencies = { + "nvim-lua/plenary.nvim", + "stevearc/dressing.nvim", + "m00qek/baleia.nvim", + }, + config = function() + vim.opt.termguicolors = true + vim.env.FLUTTER_FORCE_COLOR = "1" + + local baleia = require("baleia").setup({ + strip_ansi_codes = true, + }) + + + + vim.api.nvim_create_autocmd("BufWinEnter", { + pattern = "*__FLUTTER_DEV_LOG__*", + callback = function(args) + local bufnr = args.buf + + if not vim.bo[bufnr].modifiable then + vim.bo[bufnr].modifiable = true + end + + baleia.automatically(bufnr) + end, + }) + + vim.api.nvim_create_autocmd("OptionSet", { + pattern = "modifiable", + callback = function(args) + local bufnr = args.buf + if not vim.bo[bufnr].modifiable then + vim.bo[bufnr].modifiable = true + end + end, + }) + + require("flutter-tools").setup({ + ui = { + border = "rounded", + notification_style = "plugin", + }, + decorations = { + statusline = { + app_version = true, + device = true, + } + }, + lsp = { + capabilities = require("cmp_nvim_lsp").default_capabilities(), + settings = { + showTodos = true, + completeFunctionCalls = true, + updateImportsOnRename = true, + }, + }, + widget_guides = { + enabled = true, + }, + dev_log = { + enabled = true, + notify_errors = false, + open_cmd = "vertical rightbelow vsplit", + }, + }) + + -- Some Flutter log lines include ANSI start codes but no explicit reset. + -- Baleia keeps style state across lines, so missing reset can "bleed" + -- colors into following lines. Normalize those log lines first. + do + local ok, flutter_log = pcall(require, "flutter-tools.log") + if ok and flutter_log and type(flutter_log.log) == "function" then + local raw_log = flutter_log.log + local ansi_pattern = "\27%[[0-9;]*m" + local ansi_reset = "\27[0m" + + flutter_log.log = function(data) + if type(data) == "string" then + local has_ansi = data:find(ansi_pattern) ~= nil + local has_reset = data:find("\27%[0m") ~= nil + if has_ansi and not has_reset then + data = data .. ansi_reset + end + end + raw_log(data) + end + end + end + + -- Custom Shorthand Commands + local user_command = vim.api.nvim_create_user_command + + -- Simple Aliases + -- user_command("FRun", "FlutterRun", {}) + -- user_command("FRun", "FlutterRun --color", {}) + user_command("FRun", "FlutterRun --color", {}) + + user_command("FReload", "FlutterReload", {}) + user_command("FRestart", "FlutterRestart", {}) + user_command("FQuit", "FlutterQuit", {}) + user_command("FDevices", "FlutterDevices", {}) + user_command("FEmulators", "FlutterEmulators", {}) + user_command("FLogs", "FlutterLogToggle", {}) + user_command("FLogsClear", "FlutterLogClear", {}) + + -- Target-specific Run Command + user_command("FRunT", function(opts) + vim.cmd("FlutterRun --color --target=" .. opts.args) + end, { + nargs = 1, + complete = "file", + desc = "Run Flutter with a specific target file", + }) + end, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 95d3667..213dcf9 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -8,10 +8,12 @@ return { }, config = function() require("mason").setup() - local mason_lspconfig = require("mason-lspconfig") - -- We no longer need: local lspconfig = require("lspconfig") - local capabilities = require("cmp_nvim_lsp").default_capabilities() + + -- Register global capabilities for all servers + vim.lsp.config("*", { + capabilities = require("cmp_nvim_lsp").default_capabilities(), + }) local servers = { "lua_ls", @@ -31,41 +33,36 @@ return { ensure_installed = servers, }) - -- Neovim 0.11+ approach: Use vim.lsp.config + -- Neovim 0.11+ approach: Configure and Enable for _, server_name in ipairs(servers) do - local config = { - capabilities = capabilities, - } - if server_name == "lua_ls" then - config.settings = { - Lua = { - diagnostics = { globals = { "vim" } }, + vim.lsp.config("lua_ls", { + settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + }, }, - } + }) end - - -- Enable the server configuration natively - vim.lsp.config(server_name, config) + -- Activate the server vim.lsp.enable(server_name) end -- Diagnostic display config vim.diagnostic.config({ - virtual_text = true, -- show error inline at end of line + virtual_text = true, signs = true, underline = true, - update_in_insert = false, -- only update after leaving insert mode - float = { - border = "rounded", - source = true, -- shows which LSP reported the error - }, + update_in_insert = false, + float = { border = "rounded", source = true }, }) - -- Keybindings (unchanged) + -- Keybindings & Formatting vim.api.nvim_create_autocmd("LspAttach", { callback = function(ev) local opts = { buffer = ev.buf } + -- Neovim 0.11+ provides some defaults like 'grn' (rename), + -- but keeping your custom ones is fine. vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) vim.keymap.set("n", "", vim.lsp.buf.hover, opts) vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) @@ -78,8 +75,7 @@ return { vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next error vim.keymap.set("n", "el", vim.diagnostic.setloclist, opts) -- all errors in quickfix list vim.keymap.set("n", "af", vim.lsp.buf.format, { desc = "Format file" }) -- manual format - - -- Format on save + -- Format on save (with filter to prevent multi-client conflicts) vim.api.nvim_create_autocmd("BufWritePre", { buffer = ev.buf, callback = function() @@ -90,34 +86,13 @@ return { }) end, }, - { - "nvim-flutter/flutter-tools.nvim", - lazy = false, -- Load on startup to ensure it handles dartls correctly - dependencies = { - "nvim-lua/plenary.nvim", - "stevearc/dressing.nvim", -- Optional but highly recommended for better UI - }, - config = function() - require("flutter-tools").setup({ - lsp = { - -- Pass your existing capabilities to the flutter-tools LSP config - capabilities = require("cmp_nvim_lsp").default_capabilities(), - -- You can add specific dartls settings here if needed - settings = { - showTodos = true, - completeFunctionCalls = true, - }, - }, - }) - end, - }, { "hrsh7th/nvim-cmp", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", - "L3MON4D3/LuaSnip", -- Snippet engine is usually required by cmp configs + "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", }, config = function() @@ -129,11 +104,9 @@ return { end, }, mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping(function(fallback) -- add this + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.confirm({ select = true }) else @@ -146,6 +119,7 @@ return { { name = "luasnip" }, }, { { name = "buffer" }, + { name = "path" }, }), }) end,