Neovim定制方法

 
Category: Tips

写在前面

基于ayamir/nvimdots: A well configured and structured Neovim. (github.com);

文件

.
├── core
│   ├── event.lua
│   ├── global.lua
│   ├── init.lua
│   ├── mapping.lua
│   ├── options.lua
│   ├── pack.lua
│   ├── run.lua
│   └── settings.lua
├── keymap
│   ├── bind.lua
│   ├── config.lua
│   └── init.lua
└── modules
    ├── .DS_Store
    ├── added
    ├── completion
    ├── editor
    ├── lang
    ├── tools
    ├── ui
    └── utils

core部分

init

    require("core.run")
    pack.load_compile()

    vim.api.nvim_command([[colorscheme edge]])

    -- set cn to multi change
    vim.api.nvim_command([[
        let g:mc = "y/\\V\<C-r>=escape(@\", '/')\<CR>\<CR>"
        vnoremap <expr> cn g:mc . "``cgn"
        vnoremap <expr> cN g:mc . "``cgN"
        function! SetupCR()
          nnoremap <Enter> :nnoremap <lt>Enter> n@z<CR>q:<C-u>let @z=strpart(@z,0,strlen(@z)-1)<CR>n@z
        endfunction
        nnoremap cq :call SetupCR()<CR>*``qz
        nnoremap cQ :call SetupCR()<CR>#``qz
        vnoremap <expr> cq ":\<C-u>call SetupCR()\<CR>" . "gv" . g:mc . "``qz"
        vnoremap <expr> cQ ":\<C-u>call SetupCR()\<CR>" . "gv" . substitute(g:mc, '/', '?', 'g') . "``qz"
        ]])
end

options

        listchars = "tab:<->,space:·,nbsp:+,trail:·,extends:→,precedes:←",
        wrap = true,

        vim.g.python3_host_prog = "/opt/homebrew/bin/python3"

mappings

function vim.fn.ExecuteMacroOverVisualRange()
    vim.api.nvim_echo({ { "@" .. vim.fn.getcmdline() } }, false, {})
    vim.fn.execute(":'<,'>normal @" .. vim.fn.nr2char(vim.fn.getchar()))
end

    -- set multi visual Insert normal mode
    ["x|@"] = map_cu("lua vim.fn.ExecuteMacroOverVisualRange()"),
    -- select and change
    ["n|cn"] = map_cmd("*``cgn"):with_noremap(),
    ["n|cN"] = map_cmd("*``cgN"):with_noremap(),
    -- edit config file
    ["n|<C-,>"] = map_cmd(":e ~/.config/nvim/lua/<CR>"):with_noremap():with_silent(),
    ["n|<C-a>"] = map_cmd("ggyG"):with_noremap():with_silent(),
    -- quit!
    ["n|<C-q>"] = map_cmd(":q!<CR>"):with_silent(),


    -- edit config file
    ["i|<C-,>"] = map_cmd("<ESC>:e ~/.config/nvim/lua/<CR>"):with_noremap():with_silent(),
    -- insert full path here
    ["i|<C-t>"] = map_cmd([[<C-R>=expand("%:p:h") . "/" <CR>]]):with_noremap():with_silent(),


    ["i|<C-b>"] = map_cmd("<Left>"):with_noremap(),
    ["i|<C-f>"] = map_cmd("<Right>"):with_noremap(),
    ["i|<C-a>"] = map_cmd("<ESC>^i"):with_noremap(),
    ["i|<C-e>"] = map_cmd("<ESC><ESC>$a"):with_noremap(),
    ["i|<C-s>"] = map_cmd("<Esc>:retab<CR>:w<CR>"):with_noremap():with_silent(),
    ["i|<C-q>"] = map_cmd("<Esc>:q!<CR>"),
    ["i|<C-d>"] = map_cmd("<Del>"):with_noremap(),

    -- command line
    ["c|<C-b>"] = map_cmd("<Left>"):with_noremap(),
    ["c|<C-f>"] = map_cmd("<Right>"):with_noremap(),
    ["c|<C-a>"] = map_cmd("<Home>"):with_noremap(),
    ["c|<C-e>"] = map_cmd("<End>"):with_noremap(),
    ["c|<C-d>"] = map_cmd("<Del>"):with_noremap(),
    ["c|<C-h>"] = map_cmd("<BS>"):with_noremap(),
    ["c|<C-t>"] = map_cmd([[<C-R>=expand("%:p:h") . "/" <CR>]]):with_noremap(),

run

local function CodeRunner()
	--[===[========================== Global ===========================]===]
	vim.api.nvim_create_autocmd({ "InsertLeave" }, {
		callback = function()
			vim.fn.execute("silent! write")
			-- vim.notify("Autosaved!", vim.log.levels.INFO, {})
		end,
	})

	--[===[========================== Static ===========================]===]
	vim.api.nvim_create_autocmd("FileType", {
		pattern = "c",
		callback = function()
			-- -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te gcc-13 -Wshadow -Wall -std=c11 -o %:t:r.out %  && time ./%:t:r.out<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F8>",
				-- "<ESC>:w<CR>:split<CR>:te clang -Wshadow -Wall -std=c11 -o %:t:r.out % && time ./%:t:r.out<CR>",
				"<ESC>:w<CR>:split<CR>:te clang -Wshadow -Wall -std=c11 -o %:t:r.out % -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG && time ./%:t:r.out<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te gcc-13 -Wshadow -Wall -std=c11 -o %:t:r.out % && time ./%:t:r.out<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F8>",
				-- "<ESC>:w<CR>:split<CR>:te clang -Wshadow -Wall -std=c11 -o %:t:r.out % && time ./%:t:r.out<CR>",
				"<ESC>:w<CR>:split<CR>:te clang -Wshadow -Wall -std=c11 -o %:t:r.out % -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG && time ./%:t:r.out<CR>",
				{ silent = true, noremap = true }
			)
		end,
	})

	vim.api.nvim_create_autocmd("FileType", {
		pattern = "cpp",
		callback = function()
			-- -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te g++-13 -std=c++2a -Wshadow -Wall -o %:t:r.out %  && time ./%:t:r.out<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F8>",
				"<ESC>:w<CR>:split<CR>:te clang++ -std=c++2a -Wshadow -Wall -o %:t:r.out % -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG && time ./%:t:r.out<CR>",
				-- "<ESC>:w<CR>:split<CR>:te clang++ -std=c++2a -Wshadow -Wall -o %:t:r.out % && time ./%:t:r.out<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te g++-13 -std=c++2a -Wshadow -Wall -o %:t:r.out %  && time ./%:t:r.out<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F8>",
				-- "<ESC>:w<CR>:split<CR>:te clang++ -std=c++2a -Wshadow -Wall -o %:t:r.out % && time ./%:t:r.out<CR>",
				"<ESC>:w<CR>:split<CR>:te clang++ -std=c++2a -Wshadow -Wall -o %:t:r.out % -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG && time ./%:t:r.out<CR>",
				{ silent = true, noremap = true }
			)
		end,
	})

	--[===[=========================== Script ==========================]===]
	--
	vim.api.nvim_create_autocmd("FileType", {
		pattern = "python",
		callback = function()
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F7>",
				":w<CR>:split<CR>:te time /opt/homebrew/Caskroom/miniforge/base/envs/py3x/bin/python3 %<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te time /opt/homebrew/Caskroom/miniforge/base/envs/py3x/bin/python3 %<CR>",
				{ silent = true, noremap = true }
			)
		end,
	})

	vim.api.nvim_create_autocmd("FileType", {
		pattern = "lua",
		callback = function()
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te lua %<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F7>",
				":w<CR>:split<CR>:te lua %<CR>",
				{ silent = true, noremap = true }
			)
		end,
	})

	vim.api.nvim_create_autocmd("FileType", {
		pattern = "make",
		callback = function()
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te make <CR>i",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F8>",
				"<ESC>:w<CR>:split<CR>:te make clean<CR>i",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te make <CR>i",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F8>",
				"<ESC>:w<CR>:split<CR>:te make clean<CR>i",
				{ silent = true, noremap = true }
			)
		end,
	})
	vim.api.nvim_create_autocmd("FileType", {
		pattern = "cmake",
		callback = function()
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te cmake .<CR>",
				{ silent = true, noremap = true }
			)
		end,
	})

	vim.api.nvim_create_autocmd("FileType", {
		pattern = "shell",
		callback = function()
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te bash %<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te bash %<CR>",
				{ silent = true, noremap = true }
			)
		end,
	})

	--[===[==================== TypeWritting ===================]===]
	--
	vim.api.nvim_create_autocmd("FileType", {
		pattern = "tex",
		callback = function()
			vim.api.nvim_buf_set_keymap(
				0,
				"i",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te latexmk %<CR>",
				{ silent = true, noremap = true }
			)
			vim.api.nvim_buf_set_keymap(
				0,
				"n",
				"<F7>",
				"<ESC>:w<CR>:split<CR>:te latexmk %<CR>",
				{ silent = true, noremap = true }
			)
			-- vim.fn.writefile(
			--     {vim.fn.execute(":echo v:servername", "silent")},
			--     "/tmp/vimtexserver.txt")
		end,
	})
end
CodeRunner()

module

completion

  1. efm, clang-format config

    return {
        formatCommand = "clang-format -style='{BasedOnStyle: Google, IndentWidth: 4, SortIncludes: false, AccessModifierOffset: -4, ContinuationIndentWidth: 4, AlignAfterOpenBracket: true, AlignOperands: true, AlignTrailingComments: true, MaxEmptyLinesToKeep: 2, SpacesBeforeTrailingComments: 1, KeepEmptyLinesAtTheStartOfBlocks: true}'",
        formatStdin = true,
    }
         
    

ui

  1. config: comment alpha, catppuccin
  2. icon change does not show
  3. lualine, catppuccin->edge

plugins

-- ui["catppuccin/nvim"] = {
--  opt = false,
--  as = "catppuccin",
--  config = conf.catppuccin,
-- }

ui["goolord/alpha-nvim"] = {
    opt = true,
    event = "BufWinEnter",
    -- config = conf.alpha,
}

config

    require("lualine").setup({
        options = {
            icons_enabled = true,
            theme = "edge",

editor

  1. config->treesitter

            ensure_installed = {
                "bash",
                "c",
                "cpp",
                "lua",
                "go",
                "gomod",
                "json",
                "yaml",
                "latex",
                "make",
                "markdown",
                "markdown_inline",
                "python",
                "rust",
                "html",
                "javascript",
                "typescript",
                "vue",
                "css",
                "vim", -- added
                "help", -- added
            },
    
  2. config->jk

            mapping = { "jk", "jj", "kj" }, -- a table with mappings to use
         
    

tools

added

plugins:

local added = {}
local conf = require("modules.added.config")

added["numToStr/Navigator.nvim"] = {
    opt = true,
    event = "VimEnter",
    config = function()
        require("Navigator").setup()
        vim.keymap.set("n", "<C-h>", "<CMD>NavigatorLeft<CR>")
        vim.keymap.set("n", "<C-l>", "<CMD>NavigatorRight<CR>")
        vim.keymap.set("n", "<C-k>", "<CMD>NavigatorUp<CR>")
        vim.keymap.set("n", "<C-j>", "<CMD>NavigatorDown<CR>")
    end,
}
added["askfiy/nvim-picgo"] = {
    opt = true,
    ft = "markdown",
    config = function()
        require("nvim-picgo").setup()
    end,
}
added["lervag/vimtex"] = {
    config = conf.vimtex,
}
added["dccsillag/magma-nvim"] = {
    opt = true,
    ft = "python3",
    run = ":UpdateRemotePlugins",
    config = conf.magma,
}
-- added["MortenStabenau/matlab-vim"] = {
--     opt = true,
--     ft = "matlab",
--     config = function()
--         vim.cmd([[let g:matlab_executable = '/usr/bin/matlab']])
--         vim.cmd([[let g:matlab_panel_size = 50]])
--         vim.cmd([[let g:matlab_auto_start = 0]])
--     end,
-- }
-- added["molleweide/LuaSnip-snippets.nvim"] = {
--  opt = true,
--  after = "LuaSnip",
-- }
added["lewis6991/impatient.nvim"] = {
    opt = false,
}
added["jczhang02/luasnips-mathtex-snippets"] = {
    config = function()
        vim.cmd([[packadd LuaSnip]])
        vim.cmd([[packadd vimtex]])
        vim.cmd([[packadd vim-markdown]])
        require("luasnip-latex-snippets").setup({
            use_treesitter = true,
        })
        -- or setup({ use_treesitter = true })
    end,
    ft = { "tex", "markdown" },
}
added["ii14/emmylua-nvim"] = {
    opt = true,
}
added["skywind3000/asyncrun.vim"] = {
    opt = true,
    cmd = "AsyncRun",
    config = function()
        vim.g.asyncrun_open = 10
    end,
}
added["skywind3000/asynctasks.vim"] = {
    opt = true,
    cmd = "AsyncTask",
    config = function()
        vim.g.asynctask_rootmarks = { ".git", "pyproject.toml" }
    end,
}
added["preservim/vimux"] = {
    opt = true,
    after = "asyncrun.vim",
    config = function()
        vim.g.VimuxHeight = "20"
        vim.cmd([[let g:VimuxCloseOnExit = 1]])
    end,
}
added["danymat/neogen"] = {
    opt = false,
    config = function()
        require("neogen").setup({
            -- snippet_engine = "luasnip",
            languages = {
                python = {
                    template = {
                        annotation_convertion = "numpydoc",
                    },
                },
            },
        })
    end,
    requires = "nvim-treesitter/nvim-treesitter",
}
added["lambdalisue/suda.vim"] = {
    opt = false,
    config = function()
        vim.g.suda_smart_edit = 1
    end,
}
added["ludovicchabant/vim-gutentags"] = {
    opt = false,
    config = function()
        vim.g.gutentags_generate_on_new = 1
        vim.g.gutentags_generate_on_write = 1
        vim.g.gutentags_generate_on_missing = 1
        vim.g.gutentags_generate_on_empty_buffer = 0
        vim.g.gutentags_ctags_tagfile = ".tags"
    end,
}
added["preservim/vim-markdown"] = {
    opt = true,
    ft = "markdown",
    config = function()
        vim.cmd([[let g:vim_markdown_math = 1]])
    end,
}
added["kevinhwang91/nvim-hlslens"] = {
    opt = false,
    config = function()
        require("hlslens").setup()
        local kopts = { noremap = true, silent = true }

        vim.api.nvim_set_keymap(
            "n",
            "n",
            [[<Cmd>execute('normal! ' . v:count1 . 'n')<CR><Cmd>lua require('hlslens').start()<CR>]],
            kopts
        )
        vim.api.nvim_set_keymap(
            "n",
            "N",
            [[<Cmd>execute('normal! ' . v:count1 . 'N')<CR><Cmd>lua require('hlslens').start()<CR>]],
            kopts
        )
        vim.api.nvim_set_keymap("n", "*", [[*<Cmd>lua require('hlslens').start()<CR>]], kopts)
        vim.api.nvim_set_keymap("n", "#", [[#<Cmd>lua require('hlslens').start()<CR>]], kopts)
        vim.api.nvim_set_keymap("n", "g*", [[g*<Cmd>lua require('hlslens').start()<CR>]], kopts)
        vim.api.nvim_set_keymap("n", "g#", [[g#<Cmd>lua require('hlslens').start()<CR>]], kopts)

        vim.api.nvim_set_keymap("n", "<Leader>l", ":noh<CR>", kopts)
    end,
}
added["kylechui/nvim-surround"] = {
    keys = { "<C-g>s", "<C-g>S", "sa", "ssa", "sA", "ssA", "sa", "sA", "sd", "sr" },
    config = function()
        require("nvim-surround").setup({
            keymaps = {
                insert = "<C-g>s",
                insert_line = "<C-g>S",
                normal = "sa",
                normal_cur = "ssa",
                normal_line = "sA",
                normal_cur_line = "ssA",
                visual = "sa",
                visual_line = "sA",
                delete = "sd",
                change = "sr",
            },
        })
    end,
}

added["wakatime/vim-wakatime"] = { opt = false }

return added


config

local config = {}

function config.vimtex()
    vim.g.tex_flavor='latex' -- Default tex file format
    vim.g.vimtex_view_method = 'skim'
    -- allows forward search after every successful compilation
    vim.g.vimtex_view_skim_sync = 1
    -- allows change focus to skim after command `:VimtexView` is given
    vim.g.vimtex_view_skim_activate = 1

    vim.g.vimtex_indent_bib_enabled = 0
    vim.g.vimtex_indent_enabled = 0

    vim.g.vimtex_complete_enabled = 0
    -- Disable imaps (using Ultisnips)
    vim.g.vimtex_imaps_enabled = 0
    -- Do not open pdfviwer on compile
    vim.g.vimtex_view_automatic = 0
    -- Disable conceal
    vim.g.vimtex_syntax_conceal = {
        accents = 0,
        cites = 0,
        fancy = 0,
        greek = 0,
        math_bounds = 0,
        math_delimiters = 0,
        math_fracs = 0,
        math_super_sub = 0,
        math_symbols = 0,
        sections = 0,
        styles = 0,
    }
    -- Enable quickfix auto open
    -- vim.g.vimtex_quickfix_ignore_mode = 1
    vim.g.vimtex_compiler_progname = 'nvr'
    -- PDF viewer settings
    -- vim.g.vimtex_view_general_viewer = "skim"
    -- auto open quickfix on compile erros
    vim.g.vimtex_quickfix_mode = 1
    -- Latex warnings to ignore
    vim.g.vimtex_quickfix_ignore_filters = {
        "Command terminated with space",
        "LaTeX Font Warning: Font shape",
        "Package caption Warning: The option",
        [[Underfull \\hbox (badness [0-9]*) in]],
        "Package enumitem Warning: Negative labelwidth",
        [[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in]],
        [[Package caption Warning: Unused \\captionsetup]],
        "Package typearea Warning: Bad type area settings!",
        [[Package fancyhdr Warning: \\headheight is too small]],
        [[Underfull \\hbox (badness [0-9]*) in paragraph at lines]],
        "Package hyperref Warning: Token not allowed in a PDF string",
        [[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in paragraph at lines]],
    }
    vim.g.vimtex_fold_enabled = 0
    vim.g.vimtex_fold_manual = 0
    vim.g.vimtex_fold_types = {
        cmd_addplot = {
            cmds = { "addplot[+3]?" },
        },
        cmd_multi = {
            cmds = {
                "%(re)?new%(command|environment)",
                "providecommand",
                "presetkeys",
                "Declare%(Multi|Auto)?CiteCommand",
                "Declare%(Index)?%(Field|List|Name)%(Format|Alias)",
            },
        },
        cmd_single = {
            cmds = { "hypersetup", "tikzset", "pgfplotstableread", "lstset" },
        },
        cmd_single_opt = {
            cmds = { "usepackage", "includepdf" },
        },
        comments = {
            enabled = 0,
        },
        env_options = vim.empty_dict(),
        envs = {
            blacklist = {},
            whitelist = { "figure", "frame", "table", "example", "answer" },
        },
        items = {
            enabled = 0,
        },
        markers = vim.empty_dict(),
        preamble = {
            enabled = 0,
        },
        sections = {
            parse_levels = 0,
            parts = { "appendix", "frontmatter", "mainmatter", "backmatter" },
            sections = {
                "%(add)?part",
                "%(chapter|addchap)",
                "%(section|section\\*)",
                "%(subsection|subsection\\*)",
                "%(subsubsection|subsubsection\\*)",
                "paragraph",
            },
        },
    }
end

function config.magma()
    vim.cmd([[nnoremap <silent><expr> <Leader>r  :MagmaEvaluateOperator<CR>]])
    vim.cmd([[nnoremap <silent>       <Leader>rr :MagmaEvaluateLine<CR>]])
    vim.cmd([[xnoremap <silent>       <Leader>r  :<C-u>MagmaEvaluateVisual<CR>]])
    vim.cmd([[nnoremap <silent>       <Leader>rc :MagmaReevaluateCell<CR>]])
    vim.cmd([[nnoremap <silent>       <Leader>rd :MagmaDelete<CR>]])
    vim.cmd([[nnoremap <silent>       <Leader>ro :MagmaShowOutput<CR>]])

    vim.g.magma_automatically_open_output = false
    vim.g.magma_show_mimetype_debug = true
    vim.g.magma_image_provider = "ueberzug"
end


function config.rosepine()
    require("rose-pine").setup({
        -- @usage 'main'|'moon'
        dark_variant = "moon",
        bold_vert_split = false,
        dim_nc_background = true,
        disable_background = false,
        disable_float_background = false,
        disable_italics = false,
        ---@usage string hex value or named color from rosepinetheme.com/palette
        groups = {
            background = "base",
            panel = "surface",
            border = "highlight_med",
            comment = "muted",
            link = "iris",
            punctuation = "subtle",

            error = "love",
            hint = "iris",
            info = "foam",
            warn = "gold",

            headings = {
                h1 = "iris",
                h2 = "foam",
                h3 = "rose",
                h4 = "gold",
                h5 = "pine",
                h6 = "foam",
            },
        },
        -- Change specific vim highlight groups
        highlight_groups = {
            ColorColumn = { bg = "rose" },
        },
    })
end

function config.tasks()
    require("toggletasks").setup({
        debug = false,
        silent = false, -- don't show "info" messages
        short_paths = true, -- display relative paths when possible
        -- Paths (without extension) to task configuration files (relative to scanned directory)
        -- All supported extensions will be tested, e.g. '.toggletasks.json', '.toggletasks.yaml'
        search_paths = {
            "toggletasks",
            ".toggletasks",
            ".nvim/toggletasks",
        },
        -- Directories to consider when searching for available tasks for current window
        scan = {
            global_cwd = true, -- vim.fn.getcwd(-1, -1)
            tab_cwd = true, -- vim.fn.getcwd(-1, tab)
            win_cwd = true, -- vim.fn.getcwd(win)
            lsp_root = true, -- root_dir for first LSP available for the buffer
            dirs = {}, -- explicit list of directories to search
        },
        -- Language server priorities when selecting lsp_root (default is 0)
        lsp_priorities = {
            ["null-ls"] = -10,
        },
        -- Default values for task configuration options (available options described later)
        defaults = {
            close_on_exit = false,
            hidden = true,
        },
        -- Configuration of telescope pickers
        telescope = {
            spawn = {
                open_single = true, -- auto-open terminal window when spawning a single task
                show_running = false, -- include already running tasks in picker candidates
                -- Replaces default select_* actions to spawn task (and change toggleterm
                -- direction for select horiz/vert/tab)
                mappings = {
                    select_float = "<C-f>",
                    spawn_smart = "<C-a>", -- all if no entries selected, else use multi-select
                    spawn_all = "<M-a>", -- all visible entries
                    spawn_selected = nil, -- entries selected via multi-select (default <tab>)
                },
            },
            -- Replaces default select_* actions to open task terminal (and change toggleterm
            -- direction for select horiz/vert/tab)
            select = {
                mappings = {
                    select_float = "<C-f>",
                    open_smart = "<C-a>",
                    open_all = "<M-a>",
                    open_selected = nil,
                    kill_smart = "<C-q>",
                    kill_all = "<M-q>",
                    kill_selected = nil,
                    respawn_smart = "<C-s>",
                    respawn_all = "<M-s>",
                    respawn_selected = nil,
                },
            },
        },
    })
end

-- function config.grammar()
--  require("grammar-guard").init()
--  require("lspconfig").grammar_guard.setup({
--      cmd = { "/home/jczhang/.local/share/nvim/mason/bin/ltex-ls" }, -- add this if you install ltex-ls yourself
--      settings = {
--          ltex = {
--              enabled = { "latex", "tex", "bib", "markdown" },
--              language = "en",
--              diagnosticSeverity = "information",
--              setenceCacheSize = 2000,
--              additionalRules = {
--                  enablePickyRules = true,
--                  motherTongue = "en",
--              },
--              trace = { server = "verbose" },
--              dictionary = {},
--              disabledRules = {},
--              hiddenFalsePositives = {},
--          },
--      },
--  })
-- end
--
return config