init.lua
| vim.g.mapleader = " " | |
| vim.o.autocomplete = true | |
| vim.o.clipboard = "unnamedplus" | |
| vim.o.completeopt = "fuzzy,menuone,noinsert" | |
| vim.o.cursorline = true | |
| vim.o.expandtab = true | |
| vim.o.exrc = true | |
| vim.o.guicursor = "a:block,i:ver25,t:ver25,r:hor25" | |
| vim.o.mouse = "" | |
| vim.o.number = true | |
| vim.o.pumborder = "rounded" | |
| vim.o.pumheight = 10 | |
| vim.o.pummaxwidth = 50 | |
| vim.o.relativenumber = true | |
| vim.o.shiftwidth = 4 | |
| vim.o.showmode = false | |
| vim.o.showtabline = 2 | |
| vim.o.signcolumn = "yes" | |
| vim.o.splitbelow = true | |
| vim.o.splitright = true | |
| vim.o.swapfile = false | |
| vim.o.tabstop = 2 | |
| vim.o.timeoutlen = 500 | |
| vim.o.undofile = true | |
| vim.o.winborder = "rounded" | |
| vim.o.wrap = false | |
| vim.diagnostic.config { severity_sort = true, virtual_text = true } | |
| vim.keymap.set("i", "", function() return vim.fn.pumvisible() == 0 and "" or "" end, { expr = true }) | |
| vim.keymap.set("i", "", function() return vim.fn.pumvisible() == 0 and "" or "" end, { expr = true }) | |
| vim.keymap.set("i", "", function() return vim.fn.pumvisible() == 0 and "" or "" end, { expr = true }) | |
| vim.keymap.set("i", "", function() return vim.fn.pumvisible() == 0 and "" or "" end, { expr = true }) | |
| vim.keymap.set("i", "", function() return vim.fn.pumvisible() == 0 and "" or "" end, { expr = true }) | |
| vim.keymap.set("n", "", function() end) | |
| vim.keymap.set("n", "grd", vim.lsp.buf.definition) | |
| vim.keymap.set("n", "grf", vim.lsp.buf.format) | |
| vim.keymap.set("n", "qd", vim.diagnostic.setqflist) | |
| vim.keymap.set("t", "", "stopinsert") | |
| local notify = vim.notify | |
| vim.notify = function(msg, level, opts) notify(msg, level == vim.log.levels.ERROR and vim.log.levels.WARN or level, opts) end | |
| if vim.fn.exepath "git" ~= "" then | |
| vim.pack.add { "https://github.com/nvim-lualine/lualine.nvim" } | |
| require "lualine".setup { | |
| options = { component_separators = { left = "|", right = "|" }, section_separators = { left = "", right = "" }, globalstatus = true }, | |
| sections = { lualine_c = { "buffers" }, lualine_x = { "filetype" } } | |
| } | |
| end | |
| if vim.fn.exepath "git" ~= "" then | |
| vim.pack.add { "https://github.com/folke/tokyonight.nvim" } | |
| require "tokyonight".setup { | |
| style = "night", | |
| transparent = true, | |
| styles = { comments = { italic = false }, keywords = { italic = false } }, | |
| on_highlights = function(highlights, colors) | |
| highlights.PmenuBorder = { bg = colors.bg_dark, fg = colors.border_highlight } | |
| highlights.TabLineFill = { bg = colors.bg_dark } | |
| highlights.WinSeparator = { bg = colors.bg_dark, fg = colors.bg_dark } | |
| end | |
| } | |
| vim.cmd.colorscheme "tokyonight" | |
| end | |
| if vim.fn.exepath "git" and vim.fn.exepath "curl" ~= "" and vim.fn.exepath "tar" ~= "" and vim.fn.exepath "cc" ~= "" and vim.fn.exepath "tree-sitter" ~= "" then | |
| vim.pack.add { "https://github.com/nvim-treesitter/nvim-treesitter" } | |
| require "nvim-treesitter".install { "lua" } | |
| vim.api.nvim_create_autocmd("FileType", { | |
| callback = function() vim.treesitter.start() end, | |
| pattern = { "lua" } | |
| }) | |
| end | |
| if vim.fn.exepath "git" ~= "" then | |
| vim.pack.add { "https://github.com/williamboman/mason.nvim", "https://github.com/neovim/nvim-lspconfig", "https://github.com/williamboman/mason-lspconfig.nvim" } | |
| require "mason".setup() | |
| require "mason-lspconfig".setup { ensure_installed = { "lua_ls" } } | |
| vim.lsp.config("*", { capabilities = vim.lsp.protocol.make_client_capabilities() }) | |
| vim.lsp.config("lua_ls", { settings = { Lua = { diagnostics = { globals = { "vim" } } } } }) | |
| vim.api.nvim_create_autocmd("LspAttach", { | |
| callback = function(ev) | |
| if vim.lsp.get_client_by_id(ev.data.client_id):supports_method "textDocument/completion" then | |
| vim.lsp.completion.enable(true, ev.data.client_id, ev.buf, { autotrigger = true }) | |
| vim.bo[ev.buf].complete = "o" | |
| end | |
| end, | |
| }) | |
| end | |
| if vim.fn.exepath "git" and vim.fn.exepath "fzf" ~= "" then | |
| vim.pack.add { "https://github.com/ibhagwan/fzf-lua" } | |
| local FzfLua = require "fzf-lua" | |
| vim.keymap.set("n", "", function() FzfLua.combine { pickers = "buffers;oldfiles" } end) | |
| vim.keymap.set("n", "f", FzfLua.files) | |
| vim.keymap.set("n", "F", function() FzfLua.files { cwd = vim.fn.expand "%:p:h" } end) | |
| vim.keymap.set("n", "g", function() FzfLua.live_grep { cwd = vim.fn.getcwd(), resume = true } end) | |
| vim.keymap.set("n", "G", function() FzfLua.live_grep { cwd = vim.fn.expand "%:p:h", resume = true } end) | |
| end | |
| if vim.fn.exepath "git" ~= "" then | |
| vim.pack.add { "https://github.com/lewis6991/gitsigns.nvim" } | |
| local gitsigns = require "gitsigns" | |
| gitsigns.setup { | |
| on_attach = function(bufnr) | |
| vim.keymap.set("n", "hs", gitsigns.stage_hunk, { buf = bufnr }) | |
| vim.keymap.set("n", "hr", gitsigns.reset_hunk, { buf = bufnr }) | |
| vim.keymap.set("v", "hs", function() gitsigns.stage_hunk { vim.fn.line ".", vim.fn.line "v" } end) | |
| vim.keymap.set("v", "hr", function() gitsigns.reset_hunk { vim.fn.line ".", vim.fn.line "v" } end) | |
| vim.keymap.set("n", "hS", gitsigns.stage_buffer, { buf = bufnr }) | |
| vim.keymap.set("n", "hR", gitsigns.reset_buffer, { buf = bufnr }) | |
| vim.keymap.set("n", "hb", gitsigns.blame_line, { buf = bufnr }) | |
| vim.keymap.set("n", "hd", gitsigns.preview_hunk_inline, { buf = bufnr }) | |
| vim.keymap.set("n", "hD", function() | |
| vim.cmd "tab split" | |
| gitsigns.diffthis() | |
| end, { buf = bufnr }) | |
| vim.keymap.set("n", "hQ", function() gitsigns.setqflist "all" end, { buf = bufnr }) | |
| vim.keymap.set("n", "hq", gitsigns.setqflist, { buf = bufnr }) | |
| end | |
| } | |
| end | |
| if vim.fn.exepath "git" and vim.fn.exepath "claude" ~= "" then | |
| vim.pack.add { "https://github.com/coder/claudecode.nvim" } | |
| require "claudecode".setup { terminal = { provider = "none" }, diff_opts = { open_in_new_tab = true } } | |
| end |
评论
?
参与讨论