@@ -64,6 +64,7 @@ vim.opt.rtp:prepend(lazypath)
6464--
6565-- You can also configure plugins after the setup call,
6666-- as they will be available in your neovim runtime.
67+
6768require (' lazy' ).setup ({
6869 -- NOTE: First, some plugins that don't require any configuration
6970
@@ -78,7 +79,8 @@ require('lazy').setup({
7879 ' SirVer/ultisnips' ,
7980 ' honza/vim-snippets' ,
8081 ' natebosch/dartlang-snippets' ,
81-
82+ ' dart-lang/dart-vim-plugin' ,
83+ ' morhetz/gruvbox' ,
8284 -- NOTE: This is where your plugins related to LSP can be installed.
8385 -- The configuration is done below. Search for lspconfig to find it below.
8486 {
@@ -91,13 +93,12 @@ require('lazy').setup({
9193
9294 -- Useful status updates for LSP
9395 -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
94- { ' j-hui/fidget.nvim' , tag = ' legacy' , opts = {} },
96+ { ' j-hui/fidget.nvim' , tag = ' legacy' , opts = {} },
9597
9698 -- Additional lua configuration, makes nvim stuff amazing!
9799 ' folke/neodev.nvim' ,
98100 },
99101 },
100-
101102 {
102103 -- Autocompletion
103104 ' hrsh7th/nvim-cmp' ,
@@ -115,7 +116,7 @@ require('lazy').setup({
115116 },
116117
117118 -- Useful plugin to show you pending keybinds.
118- { ' folke/which-key.nvim' , opts = {} },
119+ { ' folke/which-key.nvim' , opts = {} },
119120 {
120121 -- Adds git related signs to the gutter, as well as utilities for managing changes
121122 ' lewis6991/gitsigns.nvim' ,
@@ -133,16 +134,16 @@ require('lazy').setup({
133134
134135 -- don't override the built-in and fugitive keymaps
135136 local gs = package.loaded .gitsigns
136- vim .keymap .set ({' n' , ' v' }, ' ]c' , function ()
137+ vim .keymap .set ({ ' n' , ' v' }, ' ]c' , function ()
137138 if vim .wo .diff then return ' ]c' end
138139 vim .schedule (function () gs .next_hunk () end )
139140 return ' <Ignore>'
140- end , {expr = true , buffer = bufnr , desc = " Jump to next hunk" })
141- vim .keymap .set ({' n' , ' v' }, ' [c' , function ()
141+ end , { expr = true , buffer = bufnr , desc = " Jump to next hunk" })
142+ vim .keymap .set ({ ' n' , ' v' }, ' [c' , function ()
142143 if vim .wo .diff then return ' [c' end
143144 vim .schedule (function () gs .prev_hunk () end )
144145 return ' <Ignore>'
145- end , {expr = true , buffer = bufnr , desc = " Jump to previous hunk" })
146+ end , { expr = true , buffer = bufnr , desc = " Jump to previous hunk" })
146147 end ,
147148 },
148149 },
@@ -213,7 +214,16 @@ require('lazy').setup({
213214 },
214215 build = ' :TSUpdate' ,
215216 },
216-
217+ {
218+ ' akinsho/flutter-tools.nvim' ,
219+ lazy = false ,
220+ dependencies = {
221+ ' nvim-lua/plenary.nvim' ,
222+ ' stevearc/dressing.nvim' , -- optional for vim.ui.select
223+ },
224+ config = true ,
225+ },
226+ { ' akinsho/git-conflict.nvim' , version = " *" , config = true },
217227 -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
218228 -- These are some example plugins that I've included in the kickstart repository.
219229 -- Uncomment any of the lines below to enable them.
@@ -229,13 +239,92 @@ require('lazy').setup({
229239 { import = ' custom.plugins' },
230240}, {})
231241
232- -- [[ Setting options ]]
242+ local flutterConfig = require (" flutter-tools" )
243+
244+ flutterConfig .setup {
245+ ui = {
246+ border = " rounded" ,
247+ notification_style = ' native'
248+ },
249+ decorations = {
250+ statusline = {
251+ -- set to true to be able use the 'flutter_tools_decorations.app_version' in your statusline
252+ -- this will show the current version of the flutter app from the pubspec.yaml file
253+ app_version = true ,
254+ -- set to true to be able use the 'flutter_tools_decorations.device' in your statusline
255+ -- this will show the currently running device if an application was started with a specific
256+ -- device
257+ device = true ,
258+ -- set to true to be able use the 'flutter_tools_decorations.project_config' in your statusline
259+ -- this will show the currently selected project configuration
260+ project_config = true ,
261+ }
262+ },
263+ debugger = { -- integrate with nvim dap + install dart code debugger
264+ enabled = false ,
265+ run_via_dap = false , -- use dap instead of a plenary job to run flutter apps
266+ -- if empty dap will not stop on any exceptions, otherwise it will stop on those specified
267+ -- see |:help dap.set_exception_breakpoints()| for more info
268+ exception_breakpoints = {}
269+ },
270+ root_patterns = { " .git" , " pubspec.yaml" }, -- patterns to find the root of your flutter project
271+ fvm = true , -- takes priority over path, uses <workspace>/.fvm/flutter_sdk if enabled
272+ widget_guides = {
273+ enabled = false ,
274+ },
275+ closing_tags = {
276+ highlight = " Comment" , -- highlight for the closing tag
277+ prefix = " //" , -- character to use for close tag e.g. > Widget
278+ enabled = true -- set to false to disable
279+ },
280+ dev_log = {
281+ enabled = true ,
282+ notify_errors = false , -- if there is an error whilst running then notify the user
283+ open_cmd = " tabedit" , -- command to use to open the log buffer
284+ },
285+ dev_tools = {
286+ autostart = false , -- autostart devtools server if not detected
287+ auto_open_browser = false , -- Automatically opens devtools in the browser
288+ },
289+ outline = {
290+ open_cmd = " 30vnew" , -- command to use to open the outline buffer
291+ auto_open = false -- if true this will open the outline automatically when it is first populated
292+ },
293+ lsp = {
294+ color = { -- show the derived colours for dart variables
295+ enabled = false , -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
296+ background = false , -- highlight the background
297+ background_color = nil , -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
298+ foreground = false , -- highlight the foreground
299+ virtual_text = true , -- show the highlight using virtual text
300+ virtual_text_str = " ■" , -- the virtual text character to highlight
301+ },
302+ --- OR you can specify a function to deactivate or change or control how the config is created
303+ capabilities = function (config )
304+ config .specificThingIDontWant = false
305+ return config
306+ end ,
307+ -- see the link below for details on each option:
308+ -- https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration
309+ settings = {
310+ showTodos = true ,
311+ completeFunctionCalls = true ,
312+ renameFilesWithClasses = " prompt" , -- "always"
313+ enableSnippets = true ,
314+ updateImportsOnRename = true , -- Whether to update imports and other directives when files are renamed. Required for `FlutterRename` command.
315+ }
316+ }
317+ }
318+
319+ --- i [[ Setting options ]]
233320-- See `:help vim.o`
234321-- NOTE: You can change these options as you wish!
235322
236323-- Set highlight on search
237324vim .o .hlsearch = false
238325
326+ vim .o .exrc = true
327+
239328-- Make line numbers default
240329vim .wo .number = true
241330
@@ -291,6 +380,14 @@ vim.api.nvim_create_autocmd('TextYankPost', {
291380 pattern = ' *' ,
292381})
293382
383+ -- Auto format
384+ vim .api .nvim_create_autocmd (" BufWritePre" , {
385+ buffer = buffer ,
386+ callback = function ()
387+ vim .lsp .buf .format { async = false }
388+ end
389+ })
390+
294391-- [[ Configure Telescope ]]
295392-- See `:help telescope` and `:help telescope.setup()`
296393require (' telescope' ).setup {
@@ -319,18 +416,29 @@ vim.keymap.set('n', '<leader>/', function()
319416end , { desc = ' [/] Fuzzily search in current buffer' })
320417
321418vim .keymap .set (' n' , ' <leader>gf' , require (' telescope.builtin' ).git_files , { desc = ' Search [G]it [F]iles' })
419+ vim .keymap .set (' n' , ' <leader>gs' , require (' telescope.builtin' ).git_status , { desc = ' Search [G]it [S]tatus' })
322420vim .keymap .set (' n' , ' <leader>sf' , require (' telescope.builtin' ).find_files , { desc = ' [S]earch [F]iles' })
323421vim .keymap .set (' n' , ' <leader>sh' , require (' telescope.builtin' ).help_tags , { desc = ' [S]earch [H]elp' })
324422vim .keymap .set (' n' , ' <leader>sw' , require (' telescope.builtin' ).grep_string , { desc = ' [S]earch current [W]ord' })
325423vim .keymap .set (' n' , ' <leader>sg' , require (' telescope.builtin' ).live_grep , { desc = ' [S]earch by [G]rep' })
326424vim .keymap .set (' n' , ' <leader>sd' , require (' telescope.builtin' ).diagnostics , { desc = ' [S]earch [D]iagnostics' })
327425vim .keymap .set (' n' , ' <leader>sr' , require (' telescope.builtin' ).resume , { desc = ' [S]earch [R]esume' })
328426
427+
428+ -- [[ Configure Flutter tools]]
429+ vim .keymap .set (' n' , ' <leader>r' , require (' telescope' ).extensions .flutter .commands , { desc = ' Open command Flutter' })
430+ -- fvm flutter pub get && fvm flutter packages pub ru:build_runner build --delete-conflicting-outputs
431+ vim .keymap .set (' n' , ' <leader>br' , function ()
432+ vim .api .nvim_command (" botright split new" )
433+ vim .fn .system { ' echo' , ' hi' }
434+ end , { desc = ' Flutter get pub and build runner' })
435+
329436-- [[ Configure Treesitter ]]
330437-- See `:help nvim-treesitter`
331438require (' nvim-treesitter.configs' ).setup {
332439 -- Add languages to be installed here that you want installed for treesitter
333- ensure_installed = { ' c' , ' cpp' , ' go' , ' lua' , ' python' , ' rust' , ' tsx' , ' javascript' , ' typescript' , ' vimdoc' , ' vim' },
440+ ensure_installed = { ' c' , ' cpp' , ' go' , ' lua' , ' python' , ' rust' , ' tsx' , ' javascript' , ' typescript' , ' vimdoc' , ' vim' ,
441+ ' dart' , ' prisma' },
334442
335443 -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
336444 auto_install = false ,
@@ -358,6 +466,7 @@ require('nvim-treesitter.configs').setup {
358466 [' if' ] = ' @function.inner' ,
359467 [' ac' ] = ' @class.outer' ,
360468 [' ic' ] = ' @class.inner' ,
469+ [' uc' ] = ' @comment.outer'
361470 },
362471 },
363472 move = {
@@ -398,12 +507,17 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnos
398507vim .keymap .set (' n' , ' <leader>e' , vim .diagnostic .open_float , { desc = ' Open floating diagnostic message' })
399508vim .keymap .set (' n' , ' <leader>q' , vim .diagnostic .setloclist , { desc = ' Open diagnostics list' })
400509
510+ -- Neotree
511+ vim .keymap .set (' n' , ' <leader>tt' , ' <Cmd>Neotree toggle<CR>' , { desc = " Neo[T]ree [T]oggle" })
512+ vim .keymap .set (' n' , ' <leader>tr' , ' <Cmd>Neotree reveal<CR>' , { desc = " Neo[T]ree [R]eveal" })
513+ vim .keymap .set (' n' , ' <leader>ts' , ' <Cmd>Neotree git_status<CR>' , { desc = " Neo[T]ree git [S]tatus" })
514+
401515-- [[ Configure LSP ]]
402516-- This function gets run when an LSP connects to a particular buffer.
403517local on_attach = function (_ , bufnr )
404518 -- NOTE: Remember that lua is a real programming language, and as such it is possible
405519 -- to define small helper and utility functions so you don't have to repeat yourself
406- -- many times.
520+ -- many time
407521 --
408522 -- In this case, we create a function that lets us more easily define mappings specific
409523 -- for LSP related items. It sets the mode, buffer and description for us each time.
@@ -456,9 +570,9 @@ local servers = {
456570 -- gopls = {},
457571 -- pyright = {},
458572 -- rust_analyzer = {},
459- -- tsserver = {},
460- -- html = { filetypes = { 'html', 'twig', 'hbs'} },
461-
573+ tsserver = {},
574+ prismals = {},
575+ -- html = { filetypes = { 'html', 'twig', 'hbs'} }
462576 lua_ls = {
463577 Lua = {
464578 workspace = { checkThirdParty = false },
@@ -474,6 +588,70 @@ require('neodev').setup()
474588local capabilities = vim .lsp .protocol .make_client_capabilities ()
475589capabilities = require (' cmp_nvim_lsp' ).default_capabilities (capabilities )
476590
591+
592+ -- Setup language servers.
593+ local lspconfig = require (' lspconfig' )
594+
595+ lspconfig .dartls .setup ({
596+ cmd = { " dart" , " language-server" , " --protocol=lsp" },
597+ filetypes = { " dart" },
598+ init_options = {
599+ closingLabels = true ,
600+ flutterOutline = true ,
601+ onlyAnalyzeProjectsWithOpenFiles = true ,
602+ outline = true ,
603+ suggestFromUnimportedLibraries = true ,
604+ },
605+ -- root_dir = root_pattern("pubspec.yaml"),
606+ settings = {
607+ dart = {
608+ completeFunctionCalls = true ,
609+ showTodos = true ,
610+ },
611+ },
612+ on_attach = function (client , bufnr )
613+ end ,
614+ })
615+
616+
617+ -- Global mappings.
618+ -- See `:help vim.diagnostic.*` for documentation on any of the below functions
619+ vim .keymap .set (' n' , ' <space>e' , vim .diagnostic .open_float )
620+ vim .keymap .set (' n' , ' [d' , vim .diagnostic .goto_prev )
621+ vim .keymap .set (' n' , ' ]d' , vim .diagnostic .goto_next )
622+ vim .keymap .set (' n' , ' <space>q' , vim .diagnostic .setloclist )
623+
624+ -- Use LspAttach autocommand to only map the following keys
625+ -- after the language server attaches to the current buffer
626+ vim .api .nvim_create_autocmd (' LspAttach' , {
627+ group = vim .api .nvim_create_augroup (' UserLspConfig' , {}),
628+ callback = function (ev )
629+ -- Enable completion triggered by <c-x><c-o>
630+ vim .bo [ev .buf ].omnifunc = ' v:lua.vim.lsp.omnifunc'
631+
632+ -- Buffer local mappings.
633+ -- See `:help vim.lsp.*` for documentation on any of the below functions
634+ local opts = { buffer = ev .buf }
635+ vim .keymap .set (' n' , ' gD' , vim .lsp .buf .declaration , opts )
636+ vim .keymap .set (' n' , ' gd' , vim .lsp .buf .definition , opts )
637+ vim .keymap .set (' n' , ' K' , vim .lsp .buf .hover , opts )
638+ vim .keymap .set (' n' , ' gi' , vim .lsp .buf .implementation , opts )
639+ vim .keymap .set (' n' , ' <C-k>' , vim .lsp .buf .signature_help , opts )
640+ vim .keymap .set (' n' , ' <space>wa' , vim .lsp .buf .add_workspace_folder , opts )
641+ vim .keymap .set (' n' , ' <space>wr' , vim .lsp .buf .remove_workspace_folder , opts )
642+ vim .keymap .set (' n' , ' <space>wl' , function ()
643+ print (vim .inspect (vim .lsp .buf .list_workspace_folders ()))
644+ end , opts )
645+ vim .keymap .set (' n' , ' <space>D' , vim .lsp .buf .type_definition , opts )
646+ vim .keymap .set (' n' , ' <space>rn' , vim .lsp .buf .rename , opts )
647+ vim .keymap .set ({ ' n' , ' v' }, ' <space>ca' , vim .lsp .buf .code_action , opts )
648+ vim .keymap .set (' n' , ' gr' , vim .lsp .buf .references , opts )
649+ vim .keymap .set (' n' , ' <space>f' , function ()
650+ vim .lsp .buf .format { async = true }
651+ end , opts )
652+ end ,
653+ })
654+
477655-- Ensure the servers above are installed
478656local mason_lspconfig = require ' mason-lspconfig'
479657
@@ -492,6 +670,30 @@ mason_lspconfig.setup_handlers {
492670 end
493671}
494672
673+ require (" lspconfig" ).dartls .setup ({
674+ cmd = { " dart" , " language-server" , " --protocol=lsp" },
675+ filetypes = { " dart" },
676+ init_options = {
677+ closingLabels = true ,
678+ flutterOutline = true ,
679+ onlyAnalyzeProjectsWithOpenFiles = true ,
680+ outline = true ,
681+ suggestFromUnimportedLibraries = true ,
682+ },
683+ -- root_dir = root_pattern("pubspec.yaml"),
684+ settings = {
685+ dart = {
686+ completeFunctionCalls = true ,
687+ showTodos = true ,
688+ },
689+ },
690+ on_attach = function (client , bufnr )
691+ end ,
692+ })
693+
694+ require (" telescope" ).load_extension (" flutter" )
695+
696+
495697-- [[ Configure nvim-cmp ]]
496698-- See `:help cmp`
497699local cmp = require ' cmp'
@@ -541,4 +743,25 @@ cmp.setup {
541743}
542744
543745-- The line beneath this is called `modeline`. See `:help modeline`
544- -- vim: ts=2 sts=2 sw=2 et
746+ -- vim: ts=2 sts=2 sw=2 etc
747+ require (' onedark' ).setup {
748+ colors = {
749+ bright_orange = " #ff8800" , -- define a new color
750+ green = ' #00ffaa' , -- redefine an existing color
751+ },
752+ highlights = {
753+ -- ["@keyword"] = { fg = '$green' },
754+ [" @string" ] = { fmt = ' bold,italic' , fg = ' $orange' },
755+ [" @function" ] = { sp = ' $yellow' },
756+ [" @function.builtin" ] = { fg = ' #0059ff' },
757+ [" @parameter" ] = { fg = ' $cyan' },
758+ [" @variable.builtin" ] = { fg = ' #00ffff' },
759+ [" @type.builtin" ] = { fg = ' #00ffff' },
760+ -- ["@constant"] = { fg = '$purple' }
761+ -- ["@constant"] = { fg = '$purple' }
762+ -- ["@constant.builtin"] = { fg = '$purple' }
763+ -- ["@type"] = { fg = '$purple' }
764+ }
765+ }
766+
767+ require (' onedark' ).load ()
0 commit comments