当前位置:   article > 正文

neovim 最终的配置_neovim packer

neovim packer

在这里插入图片描述

以上就是Neovim 我的最终配置

  • tabline 的效果要比 bufferline 的效果要好的多 我个人是这么认为的
  • 代码调转用的是 nvim-lsp-smag 搭配 lsp 和 lsp-config 使用可以和vscode 的跳转效果一致,支持 ctr+[鼠标左键]
  • 我从 archlinux 迁移到 centous stream 9 上 完全没有问题
  • 乱成了一锅粥的配置
local use = require("packer").use
require("packer").startup(function()
        use({
                "nvim-telescope/telescope.nvim",
                tag = "0.1.0",
                -- or                            , branch = '0.1.x',
                requires = { { "nvim-lua/plenary.nvim" }, { "BurntSushi/ripgrep" }, { "sharkdp/fd" } },
        })
        use({
                "glepnir/lspsaga.nvim",
                branch = "main",
        })
        use("weilbith/nvim-lsp-smag")
        use("jubnzv/virtual-types.nvim")
        use("wbthomason/packer.nvim")
        use("williamboman/nvim-lsp-installer")
        use("neovim/nvim-lspconfig")
        use("hrsh7th/nvim-cmp") -- Autocompletion plugin
        use("hrsh7th/cmp-path") -- Autocompletion plugin
        use("hrsh7th/cmp-buffer") -- Autocompletion plugin
        use("hrsh7th/cmp-cmdline") -- Autocompletion plugin
        use("hrsh7th/cmp-nvim-lsp") -- LSP source for nvim-cmp
        use("saadparwaiz1/cmp_luasnip") -- Snippets source for nvim-cmp
        use("L3MON4D3/LuaSnip") -- Snippets plugin
        use("windwp/nvim-autopairs")
        use("shaunsingh/nord.nvim")
        -- Packer
        use({ "sindrets/diffview.nvim", requires = "nvim-lua/plenary.nvim" })
        use({ "catppuccin/nvim", as = "catppuccin" })
        use({
                "nvim-treesitter/nvim-treesitter",
                requires = "p00f/nvim-ts-rainbow",
        })
        use("glepnir/dashboard-nvim")
        use("yamatsum/nvim-cursorline")
        use({
                "kyazdani42/nvim-tree.lua",
                requires = "kyazdani42/nvim-web-devicons",
        })
        use({
                "nvim-lualine/lualine.nvim",
                requires = { "kyazdani42/nvim-web-devicons", opt = true },
        })
        use({
                "akinsho/toggleterm.nvim",
                tag = "v2.*",
                config = function()
                        require("toggleterm").setup()
                end,
        })
        use("karb94/neoscroll.nvim")
        use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } })
        use({ "mhartington/formatter.nvim" })
        -- using packer.nvim
        use({
                "kdheepak/tabline.nvim",
                config = function()
                        require("tabline").setup({ enable = false })
                end,
                requires = { "hoob3rt/lualine.nvim", "kyazdani42/nvim-web-devicons" },
        })
end)

require("nvim-lsp-installer").setup({
        automatic_installation = false, -- automatically detect which servers to install (based on which servers are set up via lspconfig)
        ui = {
                icons = {
                        server_installed = "✓",
                        server_pending = "➜",
                        server_uninstalled = "✗",
                },
        },
})

require("lspconfig").ocamllsp.setup({ on_attach = require("virtualtypes").on_attach })

require("nvim-treesitter.configs").setup({
        highlight = {},
        -- ...
        rainbow = {
                enable = true,
                -- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
                extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
                max_file_lines = nil, -- Do not enable for files with more than n lines, int
                -- colors = {}, -- table of hex strings
                -- termcolors = {} -- table of colour name strings
        },
})

local colors = {
        red = "#ca1243",
        grey = "#a0a1a7",
        black = "#383a42",
        white = "#f3f3f3",
        light_green = "#83a598",
        orange = "#fe8019",
        green = "#8ec07c",
}

local theme = {
        normal = {
                a = { fg = colors.white, bg = colors.black },
                b = { fg = colors.white, bg = colors.grey },
                c = { fg = colors.black, bg = colors.white },
                z = { fg = colors.white, bg = colors.black },
        },
        insert = { a = { fg = colors.black, bg = colors.light_green } },
        visual = { a = { fg = colors.black, bg = colors.orange } },
        replace = { a = { fg = colors.black, bg = colors.green } },
}

local empty = require("lualine.component"):extend()
function empty:draw(default_highlight)
        self.status = ""
        self.applied_separator = ""
        self:apply_highlights(default_highlight)
        self:apply_section_separators()
        return self.status
end

-- Put proper separators and gaps between components in sections
local function process_sections(sections)
        for name, section in pairs(sections) do
                local left = name:sub(9, 10) < "x"
                for pos = 1, name ~= "lualine_z" and #section or #section - 1 do
                        table.insert(section, pos * 2, { empty, color = { fg = colors.white, bg = colors.white } })
                end
                for id, comp in ipairs(section) do
                        if type(comp) ~= "table" then
                                comp = { comp }
                                section[id] = comp
                        end
                        comp.separator = left and { right = "" } or { left = "" }
                end
        end
        return sections
end

local function search_result()
        if vim.v.hlsearch == 0 then
                return ""
        end
        local last_search = vim.fn.getreg("/")
        if not last_search or last_search == "" then
                return ""
        end
        local searchcount = vim.fn.searchcount({ maxcount = 9999 })
        return last_search .. "(" .. searchcount.current .. "/" .. searchcount.total .. ")"
end

local function modified()
        if vim.bo.modified then
                return "+"
        elseif vim.bo.modifiable == false or vim.bo.readonly == true then
                return "-"
        end
        return ""
end

require("lualine").setup({
        options = {
                theme = theme,
                component_separators = "",
                section_separators = { left = "", right = "" },
        },
        sections = process_sections({
                lualine_a = { "mode" },
                lualine_b = {
                        "branch",
                        "diff",
                        {
                                "diagnostics",
                                source = { "nvim" },
                                sections = { "error" },
                                diagnostics_color = { error = { bg = colors.red, fg = colors.white } },
                        },
                        {
                                "diagnostics",
                                source = { "nvim" },
                                sections = { "warn" },
                                diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } },
                        },
                        { "filename", file_status = false, path = 1 },
                        { modified, color = { bg = colors.red } },
                        {
                                "%w",
                                cond = function()
                                        return vim.wo.previewwindow
                                end,
                        },
                        {
                                "%r",
                                cond = function()
                                        return vim.bo.readonly
                                end,
                        },
                        {
                                "%q",
                                cond = function()
                                        return vim.bo.buftype == "quickfix"
                                end,
                        },
                },
                lualine_c = {},
                lualine_x = {},
                lualine_y = { search_result, "filetype" },
                lualine_z = { "%l:%c", "%p%%/%L" },
        }),
        inactive_sections = {
                lualine_c = { "%f %y %m" },
                lualine_x = {},
        },
})

-- Utilities for creating configurations
local util = require("formatter.util")

-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
require("formatter").setup({
        -- Enable or disable logging
        logging = true,
        -- Set the log level
        log_level = vim.log.levels.WARN,
        -- All formatter configurations are opt-in
        filetype = {
                -- Formatter configurations for filetype "lua" go here
                -- and will be executed in order
                lua = {
                        -- "formatter.filetypes.lua" defines default configurations for the
                        -- "lua" filetype
                        require("formatter.filetypes.lua").stylua,
                        -- You can also define your own configuration
                        function()
                                -- Supports conditional formatting
                                if util.get_current_buffer_file_name() == "special.lua" then
                                        return nil
                                end

                                -- Full specification of configurations is down below and in Vim help
                                -- files
                                return {
                                        exe = "stylua",
                                        args = {
                                                "--search-parent-directories",
                                                "--stdin-filepath",
                                                util.escape_path(util.get_current_buffer_file_path()),
                                                "--",
                                                "-",
                                        },
                                        stdin = true,
                                }
                        end,
                },
                c = {
                        require("formatter.filetypes.c").clangformat,
                        function()
                                if util.get_current_buffer_file_name() == "special.c" then
                                        return nil
                                end
                                return {
                                        exe = "clang-format",
                                        stdin = true,
                                }
                        end,
                },
                py = {
                        require("formatter.filetypes.python").pyright,
                        function()
                                if util.get_current_buffer_file_name() == "special.python" then
                                        return nil
                                end
                                return {
                                        exe = "pyright",
                                        stdin = true,
                                }
                        end,
                },
                cc = {
                        require("formatter.filetypes.c").clangformat,
                        function()
                                if util.get_current_buffer_file_name() == "special.c" then
                                        return nil
                                end
                                return {
                                        exe = "clang-format",
                                        stdin = true,
                                }
                        end,
                },
                cpp = {
                        require("formatter.filetypes.c").clangformat,
                        function()
                                if util.get_current_buffer_file_name() == "special.c" then
                                        return nil
                                end
                                return {
                                        exe = "clang-format",
                                        stdin = true,
                                }
                        end,
                },
                rs = {
                        require("formatter.filetypes.rust").rustfmt,
                        function()
                                if util.get_current_buffer_file_name() == "special.rust" then
                                        return nil
                                end
                                return {
                                        exe = "rustfmt",
                                        stdin = true,
                                }
                        end,
                },
                cmake = {
                        require("formatter.filetypes.cmake").cmakeformat,
                        function()
                                if util.get_current_buffer_file_name() == "special.cmakeformat" then
                                        return nil
                                end
                                return {
                                        exe = "cmake-format",
                                        stdin = true,
                                }
                        end,
                },
                -- Use the special "*" filetype for defining formatter configurations on
                -- any filetype
                ["*"] = {
                        -- "formatter.filetypes.any" defines default configurations for any
                        -- filetype
                        require("formatter.filetypes.any").remove_trailing_whitespace,
                },
        },
})

require("dapui").setup({
        icons = { expanded = "▾", collapsed = "▸" },
        mappings = {
                -- Use a table to apply multiple mappings
                expand = { "<CR>", "<2-LeftMouse>" },
                open = "o",
                remove = "d",
                edit = "e",
                repl = "r",
                toggle = "t",
        },
        -- Expand lines larger than the window
        -- Requires >= 0.7
        expand_lines = vim.fn.has("nvim-0.7"),
        -- Layouts define sections of the screen to place windows.
        -- The position can be "left", "right", "top" or "bottom".
        -- The size specifies the height/width depending on position. It can be an Int
        -- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while
        -- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
        -- Elements are the elements shown in the layout (in order).
        -- Layouts are opened in order so that earlier layouts take priority in window sizing.
        layouts = {
                {
                        elements = {
                                -- Elements can be strings or table with id and size keys.
                                { id = "scopes", size = 0.25 },
                                "breakpoints",
                                "stacks",
                                "watches",
                        },
                        size = 40, -- 40 columns
                        position = "left",
                },
                {
                        elements = {
                                "repl",
                                "console",
                        },
                        size = 0.25, -- 25% of total lines
                        position = "bottom",
                },
        },
        floating = {
                max_height = nil, -- These can be integers or a float between 0 and 1.
                max_width = nil, -- Floats will be treated as percentage of your screen.
                border = "single", -- Border style. Can be "single", "double" or "rounded"
                mappings = {
                        close = { "q", "<Esc>" },
                },
        },
        windows = { indent = 1 },
        render = {
                max_type_length = nil, -- Can be integer or nil.
        },
})

require("toggleterm").setup({
        -- size can be a number or function which is passed the current terminal
        size = function(term)
                if term.direction == "horizontal" then
                        return 15
                elseif term.direction == "vertical" then
                        return vim.o.columns * 0.40
                end
        end,
        on_open = function()
                -- Prevent infinite calls from freezing neovim.
                -- Only set these options specific to this terminal buffer.
                vim.api.nvim_set_option_value("foldmethod", "manual", { scope = "local" })
                vim.api.nvim_set_option_value("foldexpr", "0", { scope = "local" })
        end,
        open_mapping = false, -- [[<c-\>]],
        hide_numbers = true, -- hide the number column in toggleterm buffers
        shade_filetypes = {},
        shade_terminals = false,
        shading_factor = "1", -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
        start_in_insert = true,
        insert_mappings = true, -- whether or not the open mapping applies in insert mode
        persist_size = true,
        direction = "horizontal",
        close_on_exit = true, -- close the terminal window when the process exits
        shell = vim.o.shell, -- change the default shell
})

require("nvim-autopairs").setup({})

require("neoscroll").setup()

local kind_icons = {
        Text = "",
        Method = "m",
        Function = "",
        Constructor = "",
        Field = "",
        Variable = "",
        Class = "",
        Interface = "",
        Module = "",
        Property = "",
        Unit = "",
        Value = "",
        Enum = "",
        Keyword = "",
        Snippet = "",
        Color = "",
        File = "",
        Reference = "",
        Folder = "",
        EnumMember = "",
        Constant = "",
        Struct = "",
        Event = "",
        Operator = "",
        TypeParameter = "",
}

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)

local lspconfig = require("lspconfig")

-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
local servers = { "clangd", "pyright", "bashls", "cmake", "rust_analyzer", "sumneko_lua" }
for _, lsp in ipairs(servers) do
        lspconfig[lsp].setup({
                capabilities = capabilities,
        })
end

-- lua lsp config

local sumneko_root_path = "/root/.config/nvim/lua_lsp"
local sumneko_binary = sumneko_root_path .. "/bin/lua-language-server"
lspconfig["sumneko_lua"].setup({
        cmd = { sumneko_binary, "-E", sumneko_root_path .. "/bin/main.lua" },
        settings = {
                Lua = {
                        runtime = {
                                -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
                                version = "LuaJIT",
                                -- Setup your lua path
                                path = vim.split(package.path, ";"),
                        },
                        diagnostics = {
                                -- Get the language server to recognize the `vim` global
                                globals = { "vim" },
                        },
                        workspace = {
                                -- Make the server aware of Neovim runtime files
                                library = {
                                        [vim.fn.expand("$VIMRUNTIME/lua")] = true,
                                        [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
                                },
                        },
                },
        },
        capabilities = capabilities,
        on_attach = custom_lsp_attach,
})

-- luasnip setup
local luasnip = require("luasnip")

-- nvim-cmp setup
local cmp = require("cmp")
cmp.setup({
        snippet = {
                expand = function(args)
                        luasnip.lsp_expand(args.body)
                end,
        },
        mapping = cmp.mapping.preset.insert({
                ["<C-d>"] = cmp.mapping.scroll_docs(-4),
                ["<C-f>"] = cmp.mapping.scroll_docs(4),
                ["<C-Space>"] = cmp.mapping.complete(),
                ["<CR>"] = cmp.mapping.confirm({
                        behavior = cmp.ConfirmBehavior.Replace,
                        select = true,
                }),
                ["<Tab>"] = cmp.mapping(function(fallback)
                        if cmp.visible() then
                                cmp.select_next_item()
                        elseif luasnip.expand_or_jumpable() then
                                luasnip.expand_or_jump()
                        else
                                fallback()
                        end
                end, { "i", "s" }),
                ["<S-Tab>"] = cmp.mapping(function(fallback)
                        if cmp.visible() then
                                cmp.select_prev_item()
                        elseif luasnip.jumpable(-1) then
                                luasnip.jump(-1)
                        else
                                fallback()
                        end
                end, { "i", "s" }),
        }),
        formatting = {
                fields = { "kind", "abbr", "menu" },
                format = function(entry, vim_item)
                        -- Kind icons
                        vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
                        vim_item.menu = ({
                                nvim_lsp = "[LSP]",
                                ultisnips = "[Snippet]",
                                buffer = "[Buffer]",
                                path = "[Path]",
                        })[entry.source.name]
                        return vim_item
                end,
        },
        sources = {
                { name = "nvim_lsp" },
                { name = "luasnip" },
                { name = "buffer" },
                { name = "path" },
        },
})

cmp.setup.cmdline("/", {
        completion = { autocomplete = false },
        sources = {
                { name = "buffer" },
        },
})

cmp.setup.cmdline(":", {
        completion = { autocomplete = false },
        sources = cmp.config.sources({
                { name = "path" },
        }, {
                { name = "cmdline" },
        }),
})

require("nvim-treesitter.configs").setup({
        -- A list of parser names, or "all"
        ensure_installed = { "c", "lua", "python", "cmake", "cpp", "make", "bash", "rust" },
        -- Install parsers synchronously (only applied to `ensure_installed`)
        sync_install = true,
        -- Automatically install missing parsers when entering buffer
        auto_install = false,
        ---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
        -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!

        highlight = {
                enable = true,
                additional_vim_regex_highlighting = true,
        },
        rainbow = {
                enable = true,
                -- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
                extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
                max_file_lines = nil, -- Do not enable for files with more than n lines, int
                -- colors = {}, -- table of hex strings
                -- termcolors = {} -- table of colour name strings
        },
})

vim.cmd([[set noswapfile]])
vim.cmd([[set expandtab]])
vim.cmd([[set tabstop=4]])
vim.cmd([[set mouse=a]])
vim.cmd([[set selection=exclusive]])
vim.cmd([[set selectmode=mouse,key]])
vim.cmd([[set nu]])

require("nvim-tree").setup({})

require("nvim-cursorline").setup({
        cursorline = {
                enable = true,
                timeout = 1000,
                number = false,
        },
        cursorword = {
                enable = true,
                min_length = 3,
                hl = { underline = true },
        },
})

vim.cmd([[map <C-n> :ToggleTerm direction=float<CR>]])
vim.cmd([[
set guioptions-=e " Use showtabline in gui vim
set sessionoptions+=tabpages,globals " store tabpages and globals in session
]])
vim.cmd([[map <F6> :NvimTreeToggle<CR>]])
vim.g.catppuccin_flavour = "macchiato" -- latte, frappe, macchiato, mocha

-- Theme

require("catppuccin").setup()
vim.cmd([[colorscheme catppuccin]])

-- nord colorscheme
-- vim.cmd[[colorscheme nord]]

-- Lua
local actions = require("diffview.actions")

require("diffview").setup({
        diff_binaries = false, -- Show diffs for binaries
        enhanced_diff_hl = false, -- See ':h diffview-config-enhanced_diff_hl'
        git_cmd = { "git" }, -- The git executable followed by default args.
        use_icons = true, -- Requires nvim-web-devicons
        icons = {
                -- Only applies when use_icons is true.
                folder_closed = "",
                folder_open = "",
        },
        signs = {
                fold_closed = "",
                fold_open = "",
        },
        file_panel = {
                listing_style = "tree", -- One of 'list' or 'tree'
                tree_options = {
                        -- Only applies when listing_style is 'tree'
                        flatten_dirs = true, -- Flatten dirs that only contain one single dir
                        folder_statuses = "only_folded", -- One of 'never', 'only_folded' or 'always'.
                },
                win_config = {
                        -- See ':h diffview-config-win_config'
                        position = "left",
                        width = 35,
                },
        },
        file_history_panel = {
                log_options = {
                        -- See ':h diffview-config-log_options'
                        single_file = {
                                diff_merges = "combined",
                        },
                        multi_file = {
                                diff_merges = "first-parent",
                        },
                },
                win_config = {
                        -- See ':h diffview-config-win_config'
                        position = "bottom",
                        height = 16,
                },
        },
        commit_log_panel = {
                win_config = {}, -- See ':h diffview-config-win_config'
        },
        default_args = {
                -- Default args prepended to the arg-list for the listed commands
                DiffviewOpen = {},
                DiffviewFileHistory = {},
        },
        hooks = {}, -- See ':h diffview-config-hooks'
        keymaps = {
                disable_defaults = false, -- Disable the default keymaps
                view = {
                        -- The `view` bindings are active in the diff buffers, only when the current
                        -- tabpage is a Diffview.
                        ["<tab>"] = actions.select_next_entry, -- Open the diff for the next file
                        ["<s-tab>"] = actions.select_prev_entry, -- Open the diff for the previous file
                        ["gf"] = actions.goto_file, -- Open the file in a new split in the previous tabpage
                        ["<C-w><C-f>"] = actions.goto_file_split, -- Open the file in a new split
                        ["<C-w>gf"] = actions.goto_file_tab, -- Open the file in a new tabpage
                        ["<leader>e"] = actions.focus_files, -- Bring focus to the files panel
                        ["<leader>b"] = actions.toggle_files, -- Toggle the files panel.
                },
                file_panel = {
                        ["j"] = actions.next_entry, -- Bring the cursor to the next file entry
                        ["<down>"] = actions.next_entry,
                        ["k"] = actions.prev_entry, -- Bring the cursor to the previous file entry.
                        ["<up>"] = actions.prev_entry,
                        ["<cr>"] = actions.select_entry, -- Open the diff for the selected entry.
                        ["o"] = actions.select_entry,
                        ["<2-LeftMouse>"] = actions.select_entry,
                        ["-"] = actions.toggle_stage_entry, -- Stage / unstage the selected entry.
                        ["S"] = actions.stage_all, -- Stage all entries.
                        ["U"] = actions.unstage_all, -- Unstage all entries.
                        ["X"] = actions.restore_entry, -- Restore entry to the state on the left side.
                        ["R"] = actions.refresh_files, -- Update stats and entries in the file list.
                        ["L"] = actions.open_commit_log, -- Open the commit log panel.
                        ["<c-b>"] = actions.scroll_view(-0.25), -- Scroll the view up
                        ["<c-f>"] = actions.scroll_view(0.25), -- Scroll the view down
                        ["<tab>"] = actions.select_next_entry,
                        ["<s-tab>"] = actions.select_prev_entry,
                        ["gf"] = actions.goto_file,
                        ["<C-w><C-f>"] = actions.goto_file_split,
                        ["<C-w>gf"] = actions.goto_file_tab,
                        ["i"] = actions.listing_style, -- Toggle between 'list' and 'tree' views
                        ["f"] = actions.toggle_flatten_dirs, -- Flatten empty subdirectories in tree listing style.
                        ["<leader>e"] = actions.focus_files,
                        ["<leader>b"] = actions.toggle_files,
                },
                file_history_panel = {
                        ["g!"] = actions.options, -- Open the option panel
                        ["<C-A-d>"] = actions.open_in_diffview, -- Open the entry under the cursor in a diffview
                        ["y"] = actions.copy_hash, -- Copy the commit hash of the entry under the cursor
                        ["L"] = actions.open_commit_log,
                        ["zR"] = actions.open_all_folds,
                        ["zM"] = actions.close_all_folds,
                        ["j"] = actions.next_entry,
                        ["<down>"] = actions.next_entry,
                        ["k"] = actions.prev_entry,
                        ["<up>"] = actions.prev_entry,
                        ["<cr>"] = actions.select_entry,
                        ["o"] = actions.select_entry,
                        ["<2-LeftMouse>"] = actions.select_entry,
                        ["<c-b>"] = actions.scroll_view(-0.25),
                        ["<c-f>"] = actions.scroll_view(0.25),
                        ["<tab>"] = actions.select_next_entry,
                        ["<s-tab>"] = actions.select_prev_entry,
                        ["gf"] = actions.goto_file,
                        ["<C-w><C-f>"] = actions.goto_file_split,
                        ["<C-w>gf"] = actions.goto_file_tab,
                        ["<leader>e"] = actions.focus_files,
                        ["<leader>b"] = actions.toggle_files,
                },
                option_panel = {
                        ["<tab>"] = actions.select_entry,
                        ["q"] = actions.close,
                },
        },
})

vim.api.nvim_exec(
        [[
augroup FormatAutogroup
  autocmd!
  autocmd BufWritePost *.rs,*.lua,*.c,*.cc,*.cpp,*.h,*.py FormatWrite
augroup END
]],
        true
)

vim.cmd([[nmap <tab> :bn<cr>]])
vim.cmd([[nmap <C-S> :w<cr>]])
vim.cmd([[set showcmd]])
vim.cmd([[set cursorline]])

local keymap = vim.keymap.set
keymap("n", "gh", "<cmd>Lspsaga lsp_finder<CR>", { silent = true })

-- Code action
keymap("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", { silent = true })
keymap("v", "<leader>ca", "<cmd><C-U>Lspsaga range_code_action<CR>", { silent = true })

-- Rename
keymap("n", "gr", "<cmd>Lspsaga rename<CR>", { silent = true })

-- Definition preview
keymap("n", "gd", "<cmd>Lspsaga preview_definition<CR>", { silent = true })

-- Show line diagnostics
keymap("n", "<leader>cd", "<cmd>Lspsaga show_line_diagnostics<CR>", { silent = true })

-- Show cursor diagnostic
keymap("n", "<leader>cd", "<cmd>Lspsaga show_cursor_diagnostics<CR>", { silent = true })

-- Diagnsotic jump can use `<c-o>` to jump back
keymap("n", "[e", "<cmd>Lspsaga diagnostic_jump_next<CR>", { silent = true })
keymap("n", "]e", "<cmd>Lspsaga diagnostic_jump_prev<CR>", { silent = true })

-- Only jump to error
keymap("n", "[E", function()
        require("lspsaga.diagnostic").goto_prev({ severity = vim.diagnostic.severity.ERROR })
end, { silent = true })
keymap("n", "]E", function()
        require("lspsaga.diagnostic").goto_next({ severity = vim.diagnostic.severity.ERROR })
end, { silent = true })

-- Outline
keymap("n", "<leader>o", "<cmd>LSoutlineToggle<CR>", { silent = true })

-- Hover Doc
keymap("n", "K", "<cmd>Lspsaga hover_doc<CR>", { silent = true })

-- Float terminal
keymap("n", "<A-d>", "<cmd>Lspsaga open_floaterm<CR>", { silent = true })
-- if you want pass somc cli command into terminal you can do like this
-- open lazygit in lspsaga float terminal
keymap("n", "<A-d>", "<cmd>Lspsaga open_floaterm lazygit<CR>", { silent = true })
-- close floaterm
keymap("t", "<A-d>", [[<C-\><C-n><cmd>Lspsaga close_floaterm<CR>]], { silent = true })

local db = require("dashboard")
local home = os.getenv("HOME")
db.preview_command = "cat | lolcat -F 0.3"
db.preview_file_path = home .. "/.config/nvim/static/neovim.cat"
db.preview_file_height = 11
db.preview_file_width = 70
db.custom_center = {
        {
                icon = "  ",
                desc = "Find  File                              ",
                action = "Telescope find_files find_command=rg,--hidden,--files",
                shortcut = "SPC f f",
        },
        {
                icon = "  ",
                desc = "Find  word                              ",
                action = "Telescope live_grep",
                shortcut = "SPC f w",
        },
}

require("lualine").setup({
        tabline = {
                lualine_a = {},
                lualine_b = {},
                lualine_c = { require("tabline").tabline_buffers },
                lualine_x = { require("tabline").tabline_tabs },
                lualine_y = {},
                lualine_z = {},
        },
})
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604
  • 605
  • 606
  • 607
  • 608
  • 609
  • 610
  • 611
  • 612
  • 613
  • 614
  • 615
  • 616
  • 617
  • 618
  • 619
  • 620
  • 621
  • 622
  • 623
  • 624
  • 625
  • 626
  • 627
  • 628
  • 629
  • 630
  • 631
  • 632
  • 633
  • 634
  • 635
  • 636
  • 637
  • 638
  • 639
  • 640
  • 641
  • 642
  • 643
  • 644
  • 645
  • 646
  • 647
  • 648
  • 649
  • 650
  • 651
  • 652
  • 653
  • 654
  • 655
  • 656
  • 657
  • 658
  • 659
  • 660
  • 661
  • 662
  • 663
  • 664
  • 665
  • 666
  • 667
  • 668
  • 669
  • 670
  • 671
  • 672
  • 673
  • 674
  • 675
  • 676
  • 677
  • 678
  • 679
  • 680
  • 681
  • 682
  • 683
  • 684
  • 685
  • 686
  • 687
  • 688
  • 689
  • 690
  • 691
  • 692
  • 693
  • 694
  • 695
  • 696
  • 697
  • 698
  • 699
  • 700
  • 701
  • 702
  • 703
  • 704
  • 705
  • 706
  • 707
  • 708
  • 709
  • 710
  • 711
  • 712
  • 713
  • 714
  • 715
  • 716
  • 717
  • 718
  • 719
  • 720
  • 721
  • 722
  • 723
  • 724
  • 725
  • 726
  • 727
  • 728
  • 729
  • 730
  • 731
  • 732
  • 733
  • 734
  • 735
  • 736
  • 737
  • 738
  • 739
  • 740
  • 741
  • 742
  • 743
  • 744
  • 745
  • 746
  • 747
  • 748
  • 749
  • 750
  • 751
  • 752
  • 753
  • 754
  • 755
  • 756
  • 757
  • 758
  • 759
  • 760
  • 761
  • 762
  • 763
  • 764
  • 765
  • 766
  • 767
  • 768
  • 769
  • 770
  • 771
  • 772
  • 773
  • 774
  • 775
  • 776
  • 777
  • 778
  • 779
  • 780
  • 781
  • 782
  • 783
  • 784
  • 785
  • 786
  • 787
  • 788
  • 789
  • 790
  • 791
  • 792
  • 793
  • 794
  • 795
  • 796
  • 797
  • 798
  • 799
  • 800
  • 801
  • 802
  • 803
  • 804
  • 805
  • 806
  • 807
  • 808
  • 809
  • 810
  • 811
  • 812
  • 813
  • 814
  • 815
  • 816
  • 817
  • 818
  • 819
  • 820
  • 821
  • 822
  • 823
  • 824
  • 825
  • 826
  • 827
  • 828
  • 829
  • 830
  • 831
  • 832
  • 833
  • 834
  • 835
  • 836
  • 837
  • 838
  • 839
  • 840
  • 841
  • 842
  • 843
  • 844
  • 845
  • 846
  • 847
  • 848
  • 849
  • 850

dashboard 稍后修改, 会在github 上传 完整的文件,如果没啥大问题就不会在动了

最终的配置见github (https://github.com/HongDaYuGithub/neovim_config.git

环境安装比较麻烦 我找找国内的源 , 自动编译安装 有时间在搞 … …

鉴于初学编程的人,折腾 是最大的动力

Win 版本 周六周日,搞搞 一键部署

DashBoard

在这里插入图片描述

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
  

闽ICP备14008679号