Browse Source

my doom config for neovim 0.8

Signed-off-by: surenyi <surenyi82@qq.com>
my-config
surenyi 2 years ago
parent
commit
7536297c36
  1. 242
      config.lua
  2. 148
      ginit.vim
  3. 5
      lua/doom/modules/features/tabline/init.lua
  4. 36
      lua/user/modules/features/vimtex/init.lua
  5. 99
      lua/user/modules/langs/cc/init.lua
  6. 32
      lua/user/modules/langs/tex/init.lua
  7. 32
      lua/user/modules/langs/zig/init.lua
  8. 36
      modules.lua

242
config.lua

@ -7,13 +7,195 @@
-- ADDING A PACKAGE
--
-- doom.use_package("EdenEast/nightfox.nvim", "sainnhe/sonokai")
doom.use_package({
"ur4ltz/surround.nvim",
config = function()
require("surround").setup({mappings_style = "sandwich"})
end
})
doom.use_package({
-- "easymotion/vim-easymotion",
-- "farmergreg/vim-lastplace",
"junegunn/vim-easy-align",
"axelf4/vim-strip-trailing-whitespace",
"jlanzarotta/bufexplorer",
"tpope/vim-repeat",
-- "tpope/vim-sensible",
-- "fatih/vim-go",
"ziglang/zig.vim",
"ollykel/v-vim",
"kana/vim-textobj-user",
"kana/vim-textobj-entire",
"kana/vim-textobj-line",
-- "kana/vim-textobj-function",
"glts/vim-textobj-comment",
-- "sgur/vim-textobj-parameter",
"wellle/targets.vim",
"michaeljsmith/vim-indent-object",
"ludovicchabant/vim-gutentags",
"skywind3000/gutentags_plus",
"skywind3000/asyncrun.vim",
"sainnhe/gruvbox-material",
"arcticicestudio/nord-vim",
})
doom.use_package({
'phaazon/hop.nvim',
branch = 'v2',
config = function()
require("hop").setup {
uppercase_labels = false,
multi_windows = true,
}
-- place this in one of your configuration file(s)
-- vim.api.nvim_set_keymap('', 'f', "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true })<cr>", {})
-- vim.api.nvim_set_keymap('', 'F', "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true })<cr>", {})
-- vim.api.nvim_set_keymap('', 't', "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true, hint_offset = -1 })<cr>", {})
-- vim.api.nvim_set_keymap('', 'T', "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true, hint_offset = 1 })<cr>", {})
vim.api.nvim_set_keymap('n', '<Leader><Leader>s', '<cmd>HopChar1<cr>', {silent=true})
vim.api.nvim_set_keymap('n', '<Leader><Leader>d', '<cmd>HopChar2<cr>', {silent=true})
end
})
-- doom.use_package({
-- "ur4ltz/surround.nvim",
-- config = function()
-- require("surround").setup({mappings_style = "sandwich"})
-- end
-- "lervag/vimtex",
-- ft={'tex'},
-- })
doom.use_package({
"navarasu/onedark.nvim",
config = function()
require("onedark").setup {
style = 'dark',
transparent = false,
term_colors = true,
ending_tildes = false,
cmp_itemkind_reverse = false,
-- toggle theme style ---
toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
toggle_style_list = {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light'}, -- List of styles to toggle between
}
end
})
doom.use_package({
"junegunn/fzf",
"junegunn/fzf.vim",
})
doom.use_package({"p00f/nvim-ts-rainbow",
after = "nvim-treesitter",
config = function()
require("nvim-treesitter.configs").setup({
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
}
})
end
})
doom.use_package({
"nvim-treesitter/nvim-treesitter-textobjects",
after = "nvim-treesitter",
config = function()
require("nvim-treesitter.configs").setup({
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["am"] = "@class.outer",
-- you can optionally set descriptions to the mappings (used in the desc parameter of nvim_buf_set_keymap
["im"] = { query = "@class.inner", desc = "Select inner part of a class region" },
},
-- You can choose the select mode (default is charwise 'v')
selection_modes = {
['@parameter.outer'] = 'v', -- charwise
['@function.outer'] = 'V', -- linewise
['@class.outer'] = '<c-v>', -- blockwise
},
-- If you set this to `true` (default is `false`) then any textobject is
-- extended to include preceding xor succeeding whitespace. Succeeding
-- whitespace has priority in order to act similarly to eg the built-in
-- `ap`.
include_surrounding_whitespace = true,
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
["<leader>A"] = "@parameter.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]]"] = "@function.outer",
["]m"] = "@class.outer",
},
goto_next_end = {
["]["] = "@function.outer",
["]M"] = "@class.outer",
},
goto_previous_start = {
["[["] = "@function.outer",
["[m"] = "@class.outer",
},
goto_previous_end = {
["[]"] = "@function.outer",
["[M"] = "@class.outer",
},
},
lsp_interop = {
enable = true,
border = 'none',
peek_definition_code = {
["<leader>df"] = "@function.outer",
["<leader>dF"] = "@class.outer",
},
},
},
})
end
})
vim.g.bufExplorerDisableDefaultKeyMapping=1
vim.g.NERDTreeHijackNetrw = 0 -- Add this line if you use NERDTree
--vim.g.lf_replace_netrw = 1 -- Open lf when vim opens a directory
doom.use_keybind(
{
'<Leader>b', name='+bufexplorer', {
{'e', '<cmd>BufExplorer<cr>', name = 'BufExplorer'},
{'t', '<cmd>ToggleBufExplorer<cr>', name = 'ToggleBufExplorer'},
}
})
vim.cmd([[
let g:gutentags_modules = ['ctags', 'gtags_cscope']
let g:gutentags_trace = 0
let g:gutentags_project_root = ['.git', '.ccls', '.svn']
let g:gutentags_cache_dir = expand('~/.cache/tags')
let g:gutentags_plus_switch = 1
]])
-- ADDING A KEYBIND
--
-- doom.use_keybind({
@ -41,8 +223,54 @@
-- { "FileType", "javascript", function() print('This is a javascript file') end }
-- })
doom.indent = 2
doom.core.treesitter.settings.show_compiler_warning_message = false
doom.core.reloader.settings.reload_on_save = false
doom.indent = 4
--doom.core.treesitter.settings.show_compiler_warning_message = false
--doom.core.reloader.settings.reload_on_save = false
--doom.langs.cc.settings.disable_lsp = true
--doom.langs.cc.settings.disable_diagnostics = true
--doom.langs.cc.settings.lsp_name = "ccls"
doom.langs.lua.settings.disable_diagnostics = true
doom.colorscheme = "onedark"
--doom.colorscheme = "nord"
doom.preserve_edit_pos = true
function _G._sugar_folds_()
return require("doom.core.functions").sugar_folds()
end
vim.opt.foldtext = 'v:lua._sugar_folds_()'
vim.defer_fn(function()
vim.opt.foldmethod="expr"
vim.opt.foldexpr="nvim_treesitter#foldexpr()"
end, 0)
doom.features.linter.settings.null_ls_settings.on_init = function(new_client, _)
new_client.offset_encoding = 'utf-32'
end
doom.features.dashboard.settings.header = {
' ',
'⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣠⣤⣤⣴⣦⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ',
'⠀⠀⠀⠀⠀⠀⢀⣤⣾⣿⣿⣿⣿⠿⠿⠿⠿⣿⣿⣿⣿⣶⣤⡀⠀⠀⠀⠀⠀⠀ ',
'⠀⠀⠀⠀⣠⣾⣿⣿⡿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢿⣿⣿⣶⡀⠀⠀⠀⠀ ',
'⠀⠀⠀⣴⣿⣿⠟⠁⠀⠀⠀⣶⣶⣶⣶⡆⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣦⠀⠀⠀ ',
'⠀⠀⣼⣿⣿⠋⠀⠀⠀⠀⠀⠛⠛⢻⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣧⠀⠀ ',
'⠀⢸⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⡇⠀ ',
'⠀⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⠀ ',
'⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⡟⢹⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀⣹⣿⣿⠀ ',
'⠀⣿⣿⣷⠀⠀⠀⠀⠀⠀⣰⣿⣿⠏⠀⠀⢻⣿⣿⡄⠀⠀⠀⠀⠀⠀⣿⣿⡿⠀ ',
'⠀⢸⣿⣿⡆⠀⠀⠀⠀⣴⣿⡿⠃⠀⠀⠀⠈⢿⣿⣷⣤⣤⡆⠀⠀⣰⣿⣿⠇⠀ ',
'⠀⠀⢻⣿⣿⣄⠀⠀⠾⠿⠿⠁⠀⠀⠀⠀⠀⠘⣿⣿⡿⠿⠛⠀⣰⣿⣿⡟⠀⠀ ',
'⠀⠀⠀⠻⣿⣿⣧⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⠏⠀⠀⠀ ',
'⠀⠀⠀⠀⠈⠻⣿⣿⣷⣤⣄⡀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⠟⠁⠀⠀⠀⠀ ',
'⠀⠀⠀⠀⠀⠀⠈⠛⠿⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠋⠁⠀⠀⠀⠀⠀⠀ ',
'⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠛⠛⠛⠛⠛⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ',
}
doom.features.dashboard.settings.footer = {"", "Happy hacking" }
-- CTRL-Z (default)
doom.disable_suspension = false
-- vim: sw=2 sts=2 ts=2 expandtab

148
ginit.vim

@ -0,0 +1,148 @@
set mouse=a
if exists(':GuiFont')
if has('win32')
GuiFont Sarasa\ Mono\ SC\ Nerd:h12
else
GuiFont Sarasa\ Mono\ SC\ Nerd:h14
endif
endif
if exists(':GuiTabline')
GuiTabline 0
endif
if exists(':GuiPopupmen')
GuiPopupmen 0
endif
" Enable GUI ScrollBar
if exists(':GuiScrollBar')
GuiScrollBar 1
endif
if exists(':GuiRenderLigatures')
GuiRenderLigatures 1
endif
if exists(':GuiWindowOpacity')
GuiWindowOpacity 0.98
endif
" Right Click Context Menu (Copy-Cut-Paste)
nnoremap <silent><RightMouse> :call GuiShowContextMenu()<CR>
inoremap <silent><RightMouse> <Esc>:call GuiShowContextMenu()<CR>
xnoremap <silent><RightMouse> :call GuiShowContextMenu()<CR>gv
snoremap <silent><RightMouse> <C-G>:call GuiShowContextMenu()<CR>gv
if exists("g:neovide")
if has("win32")
set guifont=Sarasa\ Mono\ SC\ Nerd:h12
else
set guifont=Sarasa\ Mono\ SC\ Nerd:h14
endif
if has("win32")
let g:neovide_transparency=0.9
else
" g:neovide_transparency should be 0 if you want to unify transparency of content and title bar.
let g:neovide_transparency=0.0
let g:transparency = 0.9
let g:neovide_background_color = '#0f1117'.printf('%x', float2nr(255 * g:transparency))
endif
let g:neovide_refresh_rate=120
let g:neovide_remember_window_size = v:true
let g:neovide_hide_mouse_when_typing = v:true
let g:neovide_input_use_logo=v:true " v:true on macOS, v:false (ctrl-v for pasting)
" 0 to disable
let g:neovide_cursor_animation_length=0.13
let g:neovide_cursor_trail_size=0.2
" railgun, torpedo, pixiedust, sonicboom, ripple, wireframe,
let g:neovide_cursor_vfx_mode = "railgun"
let g:neovide_cursor_vfx_opacity=200.0
endif
if exists('g:fvim_loaded')
" good old 'set guifont' compatibility with HiDPI hints...
set guifont=Sarasa\ Mono\ SC\ Nerd:h16
" Ctrl-ScrollWheel for zooming in/out
nnoremap <silent> <C-ScrollWheelUp> :set guifont=+<CR>
nnoremap <silent> <C-ScrollWheelDown> :set guifont=-<CR>
nnoremap <A-CR> :FVimToggleFullScreen<CR>
FVimCursorSmoothMove v:false
FVimCursorSmoothBlink v:true
" Background composition
" 'none', 'transparent', 'blur' or 'acrylic'
FVimBackgroundComposition 'transparent'
" value between 0 and 1, default bg opacity.
FVimBackgroundOpacity 0.96
" value between 0 and 1, non-default bg opacity.
FVimBackgroundAltOpacity 0.96
" Title bar tweaks
" themed with colorscheme
FVimCustomTitleBar v:true
" Font tweaks
FVimFontAntialias v:true
FVimFontAutohint v:true
FVimFontHintLevel 'full'
FVimFontLigature v:true
" can be 'default', '14.0', '-1.0' etc.
FVimFontLineHeight '-1.0'
FVimFontSubpixel v:true
" Disable built-in Nerd font symbols
FVimFontNoBuiltinSymbols v:false
" Font weight tuning, possible valuaes are 100..900
FVimFontNormalWeight 400
FVimFontBoldWeight 800
endif
if exists('g:fvim_loaded')
" good old 'set guifont' compatibility with HiDPI hints...
set guifont=Sarasa\ Mono\ SC\ Nerd:h16
" Ctrl-ScrollWheel for zooming in/out
nnoremap <silent> <C-ScrollWheelUp> :set guifont=+<CR>
nnoremap <silent> <C-ScrollWheelDown> :set guifont=-<CR>
nnoremap <A-CR> :FVimToggleFullScreen<CR>
FVimCursorSmoothMove v:false
FVimCursorSmoothBlink v:true
" Background composition
" 'none', 'transparent', 'blur' or 'acrylic'
FVimBackgroundComposition 'transparent'
" value between 0 and 1, default bg opacity.
FVimBackgroundOpacity 0.96
" value between 0 and 1, non-default bg opacity.
FVimBackgroundAltOpacity 0.96
" Title bar tweaks
" themed with colorscheme
FVimCustomTitleBar v:true
" Font tweaks
FVimFontAntialias v:true
FVimFontAutohint v:true
FVimFontHintLevel 'full'
FVimFontLigature v:true
" can be 'default', '14.0', '-1.0' etc.
FVimFontLineHeight '-1.0'
FVimFontSubpixel v:true
" Disable built-in Nerd font symbols
FVimFontNoBuiltinSymbols v:false
" Font weight tuning, possible valuaes are 100..900
FVimFontNormalWeight 400
FVimFontBoldWeight 800
endif

5
lua/doom/modules/features/tabline/init.lua

@ -7,7 +7,10 @@ tabline.settings = {
numbers = function(opts)
return string.format("%s", opts.id)
end,
indicator_icon = "",
indicator = {
style = "icon",
_icon = "",
},
buffer_close_icon = "",
modified_icon = "",
close_icon = "",

36
lua/user/modules/features/vimtex/init.lua

@ -0,0 +1,36 @@
local vimtex = {}
vimtex.packages = {
["vimtex"] = {
"lervag/vimtex",
commit = "5a4edf99fdd31d135cec6876d23d495ffb57c894",
ft = {"tex"},
opt = true
}
}
vimtex.configs = {}
vimtex.configs["vimtex"] = function()
vim.g.vimtex_compiler_method = "latexmk"
vim.g.tex_flavor='latex'
vim.g.tex_conceal=''
vim.g.vimtex_compiler_progname = 'nvr'
vim.cmd([[
let g:vimtex_compiler_latexmk = {
\ 'options' : [
\ '-pdf',
\ '-outdir=output',
\ '-auxdir=output',
\ '-shell-escape',
\ '-verbose',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ '-xelatex',
\ ]
\}
]])
end
return vimtex

99
lua/user/modules/langs/cc/init.lua

@ -0,0 +1,99 @@
local utils = require("doom.utils")
local cc = {}
cc.settings = {
--- disables auto installing the treesitter
--- @type boolean
disable_treesitter = false,
--- treesitter grammars to install
--- @type string|string[]
treesitter_grammars = { "c", "cpp" },
--- disables default lsp config
--- @type boolean
disable_lsp = false,
--- name of the language server
--- @type string
lsp_name = "ccls",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = {
capabilities = {
offsetEncoding = {'utf-32'},
},
init_options = {
cache = {
directory = vim.fn.expand("~/.cache/ccls-cache")
},
clang = {
resourceDir = vim.fn.expand("~/clang/14.0.0")
},
},
},
no_installer = true,
--- disables null-ls formatting sources
--- @type boolean
disable_formatting = false,
---Mason.nvim package to auto install the formatter from.
--- @type string
formatting_package = "clang-format",
--- string to access the null_ls diagnositcs provider
--- @type string
formatting_provider = "builtins.formatting.clang_format",
--- function to configure null-ls formatter
--- @type function|nil
formatting_config = nil,
--- disables null-ls diagnostic sources
--- @type boolean
disable_diagnostics = false,
--- mason.nvim package to auto install the diagnostics provider from
--- @type string
diagnostics_package = "cpplint",
--- string to access the null_ls diagnositcs provider
--- @type string
diagnostics_provider = "builtins.diagnostics.cpplint",
--- function to configure null-ls diagnostics
--- @type function|nil
diagnostics_config = nil,
}
local langs_utils = require("doom.modules.langs.utils")
cc.autocmds = {
{
"FileType",
"cpp,c",
langs_utils.wrap_language_setup("cc", function()
if not cc.settings.disable_lsp then
langs_utils.use_lsp_mason(cc.settings.lsp_name, {
config = cc.settings.lsp_config,
no_installer = cc.settings.no_installer,
})
end
if not cc.settings.disable_treesitter then
langs_utils.use_tree_sitter(cc.settings.treesitter_grammars)
end
if not cc.settings.disable_formatting then
langs_utils.use_null_ls(
cc.settings.formatting_package,
cc.settings.formatting_provider,
cc.settings.formatting_config
)
end
if not cc.settings.disable_diagnostics then
langs_utils.use_null_ls(
cc.settings.diagnostics_package,
cc.settings.diagnostics_provider,
cc.settings.diagnostics_config
)
end
end),
once = true,
},
}
return cc

32
lua/user/modules/langs/tex/init.lua

@ -0,0 +1,32 @@
local tex = {}
tex.settings = {
lsp_name = "texlab",
treesitter_grammars = { "latex", "bibtex"},
}
tex.autocmds = {
{
"BufWinEnter",
"*.tex",
function()
local langs_utils = require("doom.modules.langs.utils")
langs_utils.use_lsp_mason(doom.langs.tex.settings.lsp_name)
langs_utils.use_tree_sitter(tex.settings.treesitter_grammars)
-- Setup null-ls
if doom.modules.linter then
local null_ls = require("null-ls")
langs_utils.use_null_ls_source({
null_ls.builtins.diagnostics.chktex,
null_ls.builtins.formatting.latexindent,
})
end
end,
once = true,
},
}
return tex

32
lua/user/modules/langs/zig/init.lua

@ -0,0 +1,32 @@
local zig = {}
zig.settings = {
language_server_name = "zls",
}
zig.autocmds = {
{
"BufWinEnter",
"*.zig",
function()
local langs_utils = require("doom.modules.langs.utils")
langs_utils.use_lsp(doom.langs.zig.settings.language_server_name)
vim.defer_fn(function()
require("nvim-treesitter.install").ensure_installed("zig")
end, 0)
-- Setup null-ls
if doom.features.linter then
local null_ls = require("null-ls")
langs_utils.use_null_ls_source({
null_ls.builtins.formatting.zigfmt,
})
end
end,
once = true,
},
}
return zig

36
modules.lua

@ -26,7 +26,7 @@ return {
"indentlines", -- Show indent lines with special characters
"range_highlight", -- Highlight selected range from commands
"todo_comments", -- Highlight TODO: comments
-- "doom_themes", -- Extra themes for doom
"doom_themes", -- Extra themes for doom
-- UI Components
"lsp_progress", -- Check status of LSP loading
@ -35,8 +35,8 @@ return {
-- "trouble", -- A pretty diagnostic viewer
"statusline", -- A pretty status line at the bottom of the buffer
-- "minimap", -- Shows current position in document
-- "terminal", -- Integrated terminal in neovim
-- "symbols", -- Navigate between code symbols using telescope
"terminal", -- Integrated terminal in neovim
"symbols", -- Navigate between code symbols using telescope
-- "ranger", -- File explorer in neovim (TODO: Test)
-- "restclient", -- Test HTTP requests from neovim (TODO: Test)
-- "show_registers", -- Show and navigate between registers
@ -47,50 +47,50 @@ return {
"explorer", -- An enhanced filetree explorer
-- "firenvim", -- Embed neovim in your browser
-- "lazygit", -- Lazy git integration
-- "neogit", -- A git client for neovim
"neogit", -- A git client for neovim
"neorg", -- Organise your life
"projects", -- Quickly switch between projects
-- "superman", -- Read unix man pages in neovim
-- "suda", -- Save using sudo when necessary
"telescope", -- Fuzzy searcher to find files, grep code and more
"whichkey", -- An interactive sheet
"vimtex", -- latex
},
langs = {
-- Scripts
"lua",
"python",
-- "bash",
"bash",
-- "fish",
-- "gdscript",
-- "gdscript",
-- "php",
-- "ruby",
-- Web
-- "javascript",
-- "typescript",
-- "css",
"typescript",
"css",
-- "vue",
-- "tailwindcss",
-- "svelte",
-- Compiled
-- "rust",
-- "cc",
"rust",
"cc",
"zig",
"go",
-- "ocaml",
-- "haskell",
-- JIT
-- "c_sharp",
-- "kotlin",
-- "java",
"java",
-- "json",
-- "yaml",
-- "toml",
-- "markdown",
"json", -- JSON, YAML, TOML
"markdown",
"tex",
-- "terraform", -- Terraform / hcl files support
-- "dockerfile",
"dockerfile",
-- "nix", -- Nix declarations
},
}

Loading…
Cancel
Save