From 59fa9c7d7fedbe74bb93cba90adf17fea70f8a5d Mon Sep 17 00:00:00 2001 From: Kiruel Date: Sun, 7 Jan 2024 07:42:29 +0100 Subject: [PATCH] chore: save config --- init.lua | 125 ++++++++------------------- lua/custom/plugins/auto-hlsearch.lua | 7 ++ lua/custom/plugins/copilot.lua | 2 + lua/custom/plugins/flutter.lua | 8 +- lua/custom/plugins/telescope.lua | 55 ++++++++++++ lua/custom/plugins/tests.lua | 14 +++ lua/custom/plugins/tree.lua | 2 +- lua/kickstart/plugins/debug.lua | 1 + snippets/dart.snippets | 4 + 9 files changed, 128 insertions(+), 90 deletions(-) create mode 100644 lua/custom/plugins/auto-hlsearch.lua create mode 100644 lua/custom/plugins/telescope.lua diff --git a/init.lua b/init.lua index 2f72f823..4f055ee7 100644 --- a/init.lua +++ b/init.lua @@ -71,6 +71,7 @@ require('lazy').setup({ 'tpope/vim-fugitive', 'tpope/vim-rhubarb', + -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', @@ -149,35 +150,13 @@ require('lazy').setup({ 'lukas-reineke/indent-blankline.nvim', -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help indent_blankline.txt` - opts = { - char = '┊', - show_trailing_blankline_indent = false, - }, + main = 'ibl', + opts = {}, }, -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, - -- Fuzzy Finder (files, lsp, etc) - { - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - -- Fuzzy Finder Algorithm which requires local dependencies to be built. - -- Only load if `make` is available. Make sure you have the system - -- requirements installed. - { - 'nvim-telescope/telescope-fzf-native.nvim', - -- NOTE: If you are having trouble with this installation, - -- refer to the README for telescope-fzf-native for more instructions. - build = 'make', - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - }, - }, { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', @@ -239,7 +218,7 @@ vim.o.smartcase = true vim.wo.signcolumn = 'yes' -- Decrease update time -vim.o.updatetime = 250 +vim.o.updatetime = 100 vim.o.timeoutlen = 300 -- Set completeopt to have a better completion experience @@ -277,49 +256,18 @@ vim.api.nvim_create_autocmd("BufWritePre", { end }) --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, +vim.filetype.add({ + extension = { + arb = "json", }, -} - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') - --- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer' }) - -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'gs', require('telescope.builtin').git_status, { desc = 'Search [G]it [S]tatus' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) - +}) -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', - 'dart', 'prisma', 'graphql' }, + 'dart', 'prisma', 'graphql', 'json' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = false, @@ -396,6 +344,7 @@ vim.keymap.set("n", "n", 'bnext', { desc = "[N]ext buffer" }) vim.keymap.set("n", "p", 'bprevious', { desc = "[P]revious buffer" }) vim.keymap.set("n", "d", 'bdelete', { desc = "[D]elete buffer" }) vim.keymap.set("n", "ot", "20split | te", { desc = "[O]pen [T]erminal below" }) +vim.keymap.set("n", "vs", "vs", { desc = "[V]ertical [S]plit" }) -- Save file vim.keymap.set("n", "s", 'w', { desc = "[S]ave file" }) @@ -462,6 +411,7 @@ local servers = { tsserver = {}, prismals = {}, graphql = {}, + clangd = {}, -- prettierd = {}, -- html = { filetypes = { 'html', 'twig', 'hbs'} } lua_ls = { @@ -519,6 +469,7 @@ vim.api.nvim_create_autocmd('LspAttach', { -- Ensure the servers above are installed local mason_lspconfig = require 'mason-lspconfig' +local lspconfig = require('lspconfig') mason_lspconfig.setup { ensure_installed = vim.tbl_keys(servers), @@ -526,7 +477,7 @@ mason_lspconfig.setup { mason_lspconfig.setup_handlers { function(server_name) - require('lspconfig')[server_name].setup { + lspconfig[server_name].setup { capabilities = capabilities, on_attach = on_attach, settings = servers[server_name], @@ -535,32 +486,26 @@ mason_lspconfig.setup_handlers { end } - --- Setup language servers. -local lspconfig = require('lspconfig') - capabilities.textDocument.completion.completionItem.snippetSupport = true -lspconfig.dartls.setup({ - cmd = { "dart", "language-server", "--protocol=lsp" }, - filetypes = { "dart" }, - init_options = { - closingLabels = true, - flutterOutline = true, - onlyAnalyzeProjectsWithOpenFiles = true, - outline = true, - suggestFromUnimportedLibraries = true, - }, - capabilities = capabilities, - -- root_dir = root_pattern("pubspec.yaml"), - settings = { - dart = { - completeFunctionCalls = true, - showTodos = true, - }, - }, -}) - -require("telescope").load_extension("flutter") +-- lspconfig.dartls.setup({ +-- cmd = { "dart", "language-server", "--protocol=lsp" }, +-- filetypes = { "dart" }, +-- init_options = { +-- closingLabels = true, +-- flutterOutline = true, +-- onlyAnalyzeProjectsWithOpenFiles = true, +-- outline = true, +-- suggestFromUnimportedLibraries = true, +-- }, +-- capabilities = capabilities, +-- -- root_dir = root_pattern("pubspec.yaml"), +-- settings = { +-- dart = { +-- completeFunctionCalls = true, +-- showTodos = true, +-- }, +-- }, +-- }) -- [[ Configure nvim-cmp ]] -- See `:help cmp` @@ -576,10 +521,13 @@ cmp.setup { luasnip.lsp_expand(args.body) end, }, + completion = { + completeopt = 'menu,menuone,noinsert', + }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete {}, [''] = cmp.mapping.confirm { @@ -608,6 +556,7 @@ cmp.setup { sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, + { name = 'path' }, }, } diff --git a/lua/custom/plugins/auto-hlsearch.lua b/lua/custom/plugins/auto-hlsearch.lua new file mode 100644 index 00000000..591ea4b0 --- /dev/null +++ b/lua/custom/plugins/auto-hlsearch.lua @@ -0,0 +1,7 @@ +return { + "asiryk/auto-hlsearch.nvim", + dependencies = { "asiryk/auto-hlsearch.nvim", tag = "1.1.0" }, + config = function() + require("auto-hlsearch").setup() + end, +} diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua index 1d1d8441..9c694a9f 100644 --- a/lua/custom/plugins/copilot.lua +++ b/lua/custom/plugins/copilot.lua @@ -3,6 +3,8 @@ return { init = function() vim.g.copilot_no_tab_map = true + vim.api.nvim_set_hl(0, "CopilotSuggestion", { fg = "#83a598", italic = true }) + vim.api.nvim_set_hl(0, "CopilotAnnotation", { fg = "#83a598", italic = true }) vim.keymap.set("i", "", 'copilot#Accept("")', { expr = true, silent = true, diff --git a/lua/custom/plugins/flutter.lua b/lua/custom/plugins/flutter.lua index 43c29590..6337df2a 100644 --- a/lua/custom/plugins/flutter.lua +++ b/lua/custom/plugins/flutter.lua @@ -71,13 +71,14 @@ return { config.specificThingIDontWant = false return config end, + analysisExcludedFolders = { "./fvm/" }, -- see the link below for details on each option: -- https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration settings = { showTodos = true, completeFunctionCalls = true, renameFilesWithClasses = "prompt", -- "always" - enableSnippets = true, + -- enableSnippets = true, updateImportsOnRename = true, -- Whether to update imports and other directives when files are renamed. Required for `FlutterRename` command. } } @@ -89,6 +90,11 @@ return { vim.cmd('te fvm flutter packages pub run build_runner build --delete-conflicting-outputs') vim.cmd('2sleep | normal G') end) + vim.keymap.set('n', 'bt', function() + vim.cmd('20new') + vim.cmd('te sh scripts/create_clean_lcov_and_generate_html.sh') + vim.cmd('2sleep | normal G') + end) -- '20new | te fvm flutter pub get && fvm flutter packages pub run build_runner build --delete-conflicting-outputs | $') end }; diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua new file mode 100644 index 00000000..20d73e61 --- /dev/null +++ b/lua/custom/plugins/telescope.lua @@ -0,0 +1,55 @@ +return { + 'nvim-telescope/telescope.nvim', + tag = '0.1.5', + dependencies = { + 'nvim-lua/plenary.nvim', + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + }, + config = function() + require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, + } + + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'flutter') + + -- See `:help telescope.builtin` + vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', 'gs', require('telescope.builtin').git_status, { desc = 'Search [G]it [S]tatus' }) + vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + end +} diff --git a/lua/custom/plugins/tests.lua b/lua/custom/plugins/tests.lua index 29b15d03..00b86fc8 100644 --- a/lua/custom/plugins/tests.lua +++ b/lua/custom/plugins/tests.lua @@ -18,5 +18,19 @@ return { }, }, }) + + local neotest = require('neotest') + + vim.keymap.set('n', 'tu', function() + neotest.summary.toggle() + end, { desc = 'Test: [T]oggle [S]ummary unit tests' }) + vim.keymap.set('n', 'to', function() + neotest.output.open() + end, { desc = 'Test: [T]oggle [O]utput' }) + + + vim.keymap.set('n', 'rt', function() + neotest.run.run() + end, { desc = 'Test: [R]un [T]ests' }) end } diff --git a/lua/custom/plugins/tree.lua b/lua/custom/plugins/tree.lua index e5d47586..c19c0113 100644 --- a/lua/custom/plugins/tree.lua +++ b/lua/custom/plugins/tree.lua @@ -123,7 +123,7 @@ return { commands = {}, window = { position = "left", - width = 40, + width = 60, mapping_options = { noremap = true, nowait = true, diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index ac3885a0..223a4863 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -53,6 +53,7 @@ return { dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') end, { desc = 'Debug: Set Breakpoint' }) + -- Dap UI setup -- For more information, see |:help nvim-dap-ui| dapui.setup { diff --git a/snippets/dart.snippets b/snippets/dart.snippets index 21a90ca6..a9da30b5 100644 --- a/snippets/dart.snippets +++ b/snippets/dart.snippets @@ -8,3 +8,7 @@ # snippet tmt "Theme textTheme" Theme.of(context).textTheme.$1 +snippet phr "AppLocalizations" + AppLocalizations.of(context)!.$1 +snippet imploc "Import AppLocalizations" + import 'package:flutter_gen/gen_l10n/app_localizations.dart';