diff --git a/lunarvim/.config/lvim/config.lua b/lunarvim/.config/lvim/config.lua index 46f5a58a..3b1faf06 100644 --- a/lunarvim/.config/lvim/config.lua +++ b/lunarvim/.config/lvim/config.lua @@ -1,202 +1,42 @@ --[[ -lvim is the global options object - -Linters should be -filled in as strings with either -a global executable or a path to -an executable + THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT + `lvim` is the global options object ]] --- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT --- original: ~/.local/share/lunarvim/lvim/utils/installer/config.example.lua --- If lots of errors after reinstall, exucute: --- :LvimCacheReset and :PackerSync +-- vim options +-- vim.opt.shiftwidth = 2 +-- vim.opt.tabstop = 2 +-- vim.opt.relativenumber = true -- general --- vim.opt.shell = "/bin/bash" -lvim.log.level = "warn" -lvim.format_on_save = true -lvim.transparent_window = true -lvim.colorscheme = "default" -lvim.builtin.lualine.style = "default" -lvim.builtin.lualine.options.theme = "onedark" -lvim.builtin.lualine.sections.lualine_c = { "filename", "diagnostics" } -lvim.builtin.telescope.defaults = { - -- list the line number from Results window top->down - sorting_strategy = "ascending", - layout_config = { - prompt_position = "top", - }, -} --- debug -- dap -lvim.builtin.dap.active = true -vim.cmd([[ -" FIXME: whitespace is not highlighted -set listchars=tab:»\ ,extends:›,precedes:‹,nbsp:·,trail:·,eol:$,space:·,conceal:· -set nowrapscan -" wrap long lines, hard break long line using `gq` -set wrap -" this updatetime affects the CursorHold -set updatetime=1000 -" the offset to top/bottom for commands like z/zt/z-/zb -set scrolloff=0 -]]) -vim.api.nvim_exec( - [[ - function! ToggleWindowSplit() - if !exists('t:splitType') - let t:splitType = 'vertical' - endif - if t:splitType == 'vertical' " is vertical switch to horizontal - windo wincmd K - let t:splitType = 'horizontal' - else " is horizontal switch to vertical - windo wincmd H - let t:splitType = 'vertical' - endif - endfunction - ]], - false -) - --- Additional Plugins, --- NOTE: to compile or re-compile into ~/.config/lvim/plugin/packer_compiled.lua for packer --- after changing this block using Space-P-c/r --- https://github.com/LunarVim/LunarVim/discussions/2842#discussioncomment-3255606 -lvim.plugins = { - -- {"folke/tokyonight.nvim"}, - { "folke/trouble.nvim", cmd = "TroubleToggle" }, - { "szw/vim-maximizer" }, - -- make command needs golang installed - { - "rrethy/vim-hexokinase", - run = "make hexokinase", - config = function() - vim.cmd("let g:Hexokinase_highlighters = ['backgroundfull']") - end, - }, - { "vimlab/split-term.vim" }, - { "thinca/vim-quickrun" }, - { - "ethanholz/nvim-lastplace", - config = function() - require("nvim-lastplace").setup({ - lastplace_ignore_buftype = { "quickfix", "nofile", "help" }, - -- lastplace_ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }, - lastplace_open_folds = true, - }) - end, - }, - { - "phaazon/hop.nvim", - config = function() - require("hop").setup() - end, - }, - { - "https://gitlab.com/yorickpeterse/nvim-window.git", - config = function() - -- https://gitlab.com/yorickpeterse/nvim-window.git - require("nvim-window").setup({ - -- The characters available for hinting windows. - chars = { - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - }, - -- A group to use for overwriting the Normal highlight group in the floating - -- window. This can be used to change the background color. - normal_hl = "Normal", - -- The highlight group to apply to the line that contains the hint characters. - -- This is used to make them stand out more. - hint_hl = "Bold", - -- The border style to use for the floating window. - border = "single", - }) - end, - }, - { "theHamsta/nvim-dap-virtual-text" }, - { "rcarriga/nvim-dap-ui" }, - { "timonv/vim-cargo" }, - -- ds"(delete "), cs"'(chanage " to '), ysw"(add the next word double ") - { - "kylechui/nvim-surround", - config = function() - require("nvim-surround").setup({ - keymaps = { -- vim-surround style keymaps - -- insert = "ys", - -- visual = "S", - delete = "ds", - change = "cs", - }, - delimiters = { - pairs = { - ["("] = { "( ", " )" }, - [")"] = { "(", ")" }, - ["{"] = { "{ ", " }" }, - ["}"] = { "{", "}" }, - ["<"] = { "< ", " >" }, - [">"] = { "<", ">" }, - ["["] = { "[ ", " ]" }, - ["]"] = { "[", "]" }, - }, - separators = { - ["'"] = { "'", "'" }, - ['"'] = { '"', '"' }, - ["`"] = { "`", "`" }, - }, - HTML = { - ["t"] = true, -- Use "t" for HTML-style mappings - }, - aliases = { - ["a"] = ">", -- Single character aliases apply everywhere - ["b"] = ")", - ["B"] = "}", - ["r"] = "]", - ["q"] = { '"', "'", "`" }, -- Table aliases only apply for changes/deletions - }, - }, - }) - end, - }, - { - "lukas-reineke/indent-blankline.nvim", - config = function() - require("indent_blankline").setup({ - show_current_context = true, - show_current_context_start = true, - show_end_of_line = true, - char_highlight_list = { - -- from :highlight - "DevIconSh", - }, - }) - end, - }, +lvim.log.level = "info" +lvim.format_on_save = { + enabled = true, + -- pattern only apply format_on_save for the type + -- pattern = "*.lua", + timeout = 1000, } +-- to disable icons and use a minimalist setup, uncomment the following +lvim.use_icons = false -require("telescope").setup({ - pickers = { - find_files = { - hidden = true, - theme = "ivy", - path_display = { nil }, - }, - }, -}) - +-- keymappings -- keymappings [view all the defaults by pressing Lk] lvim.leader = "space" -- add your own keymapping -- lvim.keys.normal_mode[""] = ":w" + +-- lvim.keys.normal_mode[""] = ":BufferLineCycleNext" +-- lvim.keys.normal_mode[""] = ":BufferLineCyclePrev" + +-- -- Use which-key to add extra bindings with the leader-key prefix +-- lvim.builtin.which_key.mappings["W"] = { "noautocmd w", "Save without formatting" } +-- lvim.builtin.which_key.mappings["P"] = { "Telescope projects", "Projects" } + -- unmap a default keymapping -- lvim.keys.normal_mode[""] = false -- edit a default keymapping -- lvim.keys.normal_mode[""] = ":q" +-- remove C-l mapping which closes the term (C-\ to toggle the term) +lvim.keys.term_mode = { [""] = false } lvim.keys.normal_mode["q"] = ":q" lvim.keys.normal_mode["Q"] = ":qa!" lvim.keys.normal_mode["U"] = "" @@ -217,13 +57,13 @@ lvim.keys.normal_mode["="] = "lua vim.lsp.buf.formatting()" lvim.keys.normal_mode["=t"] = ":LvimToggleFormatOnSave" -- git related, more in g lvim.keys.normal_mode["[h"] = - "lua require 'gitsigns'.prev_hunk()lua require 'gitsigns'.preview_hunk()" +"lua require 'gitsigns'.prev_hunk()lua require 'gitsigns'.preview_hunk()" lvim.keys.normal_mode["['"] = - "lua require 'gitsigns'.prev_hunk()lua require 'gitsigns'.preview_hunk()" +"lua require 'gitsigns'.prev_hunk()lua require 'gitsigns'.preview_hunk()" lvim.keys.normal_mode["]h"] = - "lua require 'gitsigns'.next_hunk()lua require 'gitsigns'.preview_hunk()" +"lua require 'gitsigns'.next_hunk()lua require 'gitsigns'.preview_hunk()" lvim.keys.normal_mode["]'"] = - "lua require 'gitsigns'.next_hunk()lua require 'gitsigns'.preview_hunk()" +"lua require 'gitsigns'.next_hunk()lua require 'gitsigns'.preview_hunk()" lvim.keys.normal_mode["[p"] = "lua require 'gitsigns'.preview_hunk()" -- [c/]c to the prev/next diff in diffthis window lvim.keys.normal_mode["[P"] = "lua require 'gitsigns'.diffthis()" @@ -253,36 +93,39 @@ vim.api.nvim_set_keymap("x", "", ":m '<-2gv-gv", { noremap = true, sil lvim.keys.normal_mode["m"] = ":MaximizerToggle" lvim.keys.normal_mode["1"] = ":only" --- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. --- we use protected-mode (pcall) just in case the plugin wasn't loaded yet. --- local _, actions = pcall(require, "telescope.actions") --- lvim.builtin.telescope.defaults.mappings = { --- -- for input mode --- i = { --- [""] = actions.move_selection_next, --- [""] = actions.move_selection_previous, --- [""] = actions.cycle_history_next, --- [""] = actions.cycle_history_prev, --- }, --- -- for normal mode --- n = { --- [""] = actions.move_selection_next, --- [""] = actions.move_selection_previous, --- }, --- } +-- change default lsp bindings to use trouble lsp functions +-- lvim.lsp.buffer_mappings.normal_mode["g/"] = { ":Telescope lsp_document_symbols", "Lsp Document Symbols" } +lvim.lsp.buffer_mappings.normal_mode["g/"] = { "Lspsaga outline", "Lsp Symbols" } +lvim.lsp.buffer_mappings.normal_mode["gh"] = { "Lspsaga lsp_finder", "Lsp Symbol Finder" } +lvim.lsp.buffer_mappings.normal_mode["ga"] = { "Lspsaga code_action", "Lsp Code Action" } +lvim.lsp.buffer_mappings.normal_mode["gl"] = { "lua vim.lsp.codelens.run()", "Lsp CodeLens Actions" } +-- C-c v/i in the peek window to edit the file in split window, C-c o to open it +lvim.lsp.buffer_mappings.normal_mode["gd"] = { "Lspsaga peek_definition", "Lsp Definition Peek" } +lvim.lsp.buffer_mappings.normal_mode["gD"] = { ":vsplitLspsaga goto_definition", "Lsp Definition Goto" } +lvim.lsp.buffer_mappings.normal_mode["gi"] = { "Lspsaga incoming_calls", "Lsp Incoming Calls" } +lvim.lsp.buffer_mappings.normal_mode["gI"] = { "Lspsaga outgoing_calls", "Lsp Outgoing Calls" } +lvim.lsp.buffer_mappings.normal_mode["gt"] = { "Lspsaga peek_type_definition", "Lsp Type Peek" } +lvim.lsp.buffer_mappings.normal_mode["gT"] = { "Lspsaga goto_type_definition", "Lsp Type Goto" } +-- there are `Lspsaga diagnostic_jump_prev/next` commands +lvim.lsp.buffer_mappings.normal_mode["gL"] = { "Lspsaga show_buf_diagnostics", "Lsp Buffer Diagnostics" } +lvim.lsp.buffer_mappings.normal_mode["gr"] = { "Lspsaga rename", "Lsp Rename" } +lvim.lsp.buffer_mappings.normal_mode["gR"] = { "Lspsaga rename ++project", "Lsp Rename Proj" } +lvim.lsp.buffer_mappings.normal_mode["gS"] = { "Trouble lsp_references", "Lsp References" } --- Bindings: --- get all the bindings using: -- `lvim --headless +'lua require("lvim.utils").generate_settings()' +qa && sort -o lv-settings.lua{,}` -- Use which-key to add extra bindings with the leader-key prefix -- from vimlab/split-term.vim -- NOTE: C-l in the terminal to toggle the terminal back to the editor +-- C-l by default to toggle the terminal lvim.builtin.which_key.mappings[""] = { ":lua require('nvim-window').pick()", "Choose Windows" } +lvim.builtin.which_key.mappings["'"] = { ":ToggleTerm", "Toggle Terminal" } +lvim.builtin.which_key.mappings["vv"] = { ":ToggleTerm", "Toggle Terminal" } lvim.builtin.which_key.mappings["v\\"] = { ":VTerm", "| Term" } lvim.builtin.which_key.mappings["v-"] = { ":Term", "- Term" } lvim.builtin.which_key.mappings["b"] = { "Telescope buffers", "Switch Buffers" } -- builtin be to choose a buffer to delete lvim.builtin.which_key.mappings["bd"] = { ":bd", "Close/Delete Current Buffer" } +lvim.builtin.which_key.mappings["bw"] = { "%s/\\s\\+$//e:noh", "Trail Whitespace Clean" } lvim.builtin.which_key.mappings["xx"] = { ":QuickRun", "QuickRun" } lvim.builtin.which_key.mappings["rl"] = { ":Telescope resume", "Resume" } lvim.builtin.which_key.mappings["ss"] = { @@ -296,7 +139,17 @@ lvim.builtin.which_key.mappings["/"] = { ":Telescope current_buffer_fuzzy_find f lvim.builtin.which_key.mappings["sP"] = { "Telescope live_grep", "Live Search" } lvim.builtin.which_key.mappings["l/"] = { ":Telescope lsp_document_symbols", "Document Symbols" } lvim.builtin.which_key.mappings["l."] = { ":Telescope lsp_workspace_symbols", "Workspace Symbols" } -lvim.builtin.which_key.mappings["dI"] = { ':lua require("dapui").eval()', "Hover Info" } +lvim.builtin.which_key.mappings["LL"] = { ":Lazy", "Lazy Plugins Manager" } +lvim.builtin.which_key.mappings["dI"] = { ':lua require("dapui").eval()', "Dap Hover Info" } +lvim.builtin.which_key.mappings["dl"] = { ':lua require("dap").run_last()', "Dap Run Last Debug" } +lvim.builtin.which_key.mappings["dv"] = { + ":lua local widgets = require('dap.ui.widgets'); local sidebar = widgets.sidebar(widgets.scopes); sidebar.open();", + "Dap Varaibles Sidebar", +} +lvim.builtin.which_key.mappings["dS"] = { + ":RustDebuggables", + "Rust Start Debug", +} lvim.builtin.which_key.mappings["d"] = { ':lua require("dapui").toggle()', "Dapui Toggle" } lvim.builtin.which_key.mappings["dQ"] = { -- bind multiple commands into one key @@ -307,7 +160,7 @@ lvim.builtin.which_key.mappings["dQ"] = { lvim.builtin.which_key.mappings["t"] = { name = "+Toggle", -- from rrethy/vim-hexokinase - c = { ":HexokinaseToggle", "Toggle Color" }, + -- c = { ":HexokinaseToggle", "Toggle Color" }, w = { ":set list!", "Toggle Whitespace" }, l = { ":set wrap!", "Wrap Lines" }, } @@ -335,16 +188,6 @@ lvim.builtin.which_key.mappings["h"] = { b = { "Telescope keymaps fuzzy=false", "Keybindings" }, H = { "Telescope highlights", "Higlights" }, } --- rewrite them under P, original is p -lvim.builtin.which_key.mappings["P"] = { - name = "+Packer", - c = { "PackerCompile", "Compile" }, - i = { "PackerInstall", "Install" }, - r = { "lua require('lvim.plugin-loader').recompile()", "Re-compile" }, - s = { "PackerSync", "Sync" }, - S = { "PackerStatus", "Status" }, - u = { "PackerUpdate", "Update" }, -} lvim.builtin.which_key.mappings["f"] = { name = "+Files", F = { "Telescope find_files", "Find Project Files" }, @@ -377,41 +220,156 @@ lvim.builtin.which_key.mappings["w"] = { [""] = { "", "Switch to Down window" }, [""] = { ":call ToggleWindowSplit()", "Toggle Layout" }, } -lvim.builtin.which_key.mappings["j"] = { - name = "+Jump", - w = { ":HopWord", "Jump Word" }, - l = { ":HopLine", "Jump Line" }, - j = { ":HopChar2", "Jump Chars" }, -} lvim.builtin.which_key.mappings["lt"] = { name = "+Trouble", r = { "Trouble lsp_references", "References" }, d = { "Trouble lsp_definitions", "Definitions" }, - l = { "Trouble lsp_document_diagnostics", "Diagnostics" }, + D = { "Trouble document_diagnostics", "Diagnostics" }, q = { "Trouble quickfix", "QuickFix" }, L = { "Trouble loclist", "LocationList" }, - w = { "Trouble lsp_workspace_diagnostics", "Workspace Diagnostics" }, + w = { "Trouble workspace_diagnostics", "Workspace Diagnostics" }, } -lvim.builtin.which_key.mappings["lc"] = { +lvim.builtin.which_key.mappings["C"] = nil +lvim.builtin.which_key.mappings["c"] = { name = "+Cargo", - [""] = { ":CargoBuild", "Build" }, - b = { ":CargoBuild", "Build" }, - B = { ":CargoBench", "Benchmarks" }, - c = { ":CargoCheck", "Check" }, - C = { ":CargoClean", "Clean" }, - d = { ":CargoDoc", "Doc" }, - n = { ":CargoNew", "New" }, - x = { ":CargoRun", "Run" }, - r = { ":CargoRun", "Run" }, - R = { ":CargoReload", "Reload" }, - t = { ":CargoTest", "Test" }, - u = { ":CargoUpdate", "Update" }, + [""] = { ":CargoBuild", "Cargo build" }, + a = { ":lua require('crates').update_crate()", "Crates Update" }, + A = { ":lua require('crates').update_all_crates()", "Crates Update All" }, + b = { ":CargoBuild", "Cargo build" }, + B = { ":CargoBench", "Cargo benchmarks" }, + c = { ":CargoCheck", "Cargo check" }, + C = { ":CargoClean", "Cargo clean" }, + d = { ":CargoDoc", "Cargo doc" }, + i = { ":lua require('crates').open_crates_io()", "Crates.io Page" }, + I = { ":lua require('crates').open_documentation()", "Crate Document" }, + n = { ":CargoNew", "Cargo new" }, + x = { ":CargoRun", "Cargo run" }, + R = { ":CargoReload", "Cargp reload" }, + t = { ":CargoTest", "Cargo test" }, + u = { ":CargoUpdate", "Cargo update" }, +} +lvim.builtin.which_key.mappings["S"] = { + name = "+SearchReplace", + s = { ":lua require('spectre').open()", "SearchReplace Project" }, + S = { ":lua require('spectre').open({select_word=true})", "SearchReplace Project CW" }, + b = { ":lua require('spectre').open_file_search()", "SearchReplace CurrentBuffer" }, + B = { ":lua require('spectre').open_file_search({select_word=true})", "SearchReplace CurrentBuffer CW" }, } --- TODO: User Config for predefined plugins --- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -lvim.builtin.notify.active = true +-- -- Change theme settings +lvim.colorscheme = "default" + +lvim.transparent_window = true +lvim.builtin.lualine.style = "default" +lvim.builtin.lualine.options.theme = "onedark" +lvim.builtin.lualine.sections.lualine_c = { "filename", "diagnostics" } +lvim.builtin.telescope.defaults = { + -- list the line number from Results window top->down + sorting_strategy = "ascending", + layout_config = { + prompt_position = "top", + }, +} + +-- vim configs +vim.cmd([[ +set listchars=tab:»\ ,extends:›,precedes:‹,nbsp:·,trail:·,eol:$,space:·,conceal:· +" treat leading/trail whitespace as error +match errorMsg /\s\+$/ +set nowrapscan +" wrap long lines, hard break long line using `gq` +set wrap +" this updatetime affects the CursorHold +set updatetime=1000 +" the offset to top/bottom for commands like z/zt/z-/zb +set scrolloff=0 +" be able to open file with more encodings +set fileencodings=utf8,gb2312,gb18030,ucs-bom,latin1 +" if v:version < 800 +" set cmdheight=1 +" else +" set cmdheight=0 +" endif + +function! ToggleWindowSplit() + if !exists('t:splitType') + let t:splitType = 'vertical' + endif + if t:splitType == 'vertical' " is vertical switch to horizontal + windo wincmd K + let t:splitType = 'horizontal' + else " is horizontal switch to vertical + windo wincmd H + let t:splitType = 'vertical' + endif +endfunction +]]) + +-- TODO +lvim.builtin.alpha.active = true +lvim.builtin.alpha.mode = "dashboard" lvim.builtin.terminal.active = true +-- disable nvimtree since a bug: LunarVim/issues/2512 +lvim.builtin.nvimtree.active = false +-- lvim.builtin.nvimtree.setup.view.side = "left" +-- lvim.builtin.nvimtree.setup.renderer.icons.show.git = false + +-- Automatically install missing parsers when entering buffer +lvim.builtin.treesitter.auto_install = true + +lvim.builtin.treesitter.ignore_install = { "haskell" } + +-- -- always installed on startup, useful for parsers without a strict filetype +-- lvim.builtin.treesitter.ensure_installed = { "comment", "markdown_inline", "regex" } + +-- -- generic LSP settings + +-- --- disable automatic installation of servers +-- lvim.lsp.installer.setup.automatic_installation = false + +-- ---configure a server manually. IMPORTANT: Requires `:LvimCacheReset` to take effect +-- ---see the full default list `:lua =lvim.lsp.automatic_configuration.skipped_servers` +-- vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" }) +vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "rust_analyzer" }) +-- local opts = {} -- check the lspconfig documentation for a list of all possible options +-- require("lvim.lsp.manager").setup("pyright", opts) + +-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. IMPORTANT: Requires `:LvimCacheReset` to take effect +-- ---`:LvimInfo` lists which server(s) are skipped for the current filetype +-- lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(server) +-- return server ~= "emmet_ls" +-- end, lvim.lsp.automatic_configuration.skipped_servers) + +-- https://github.com/folke/trouble.nvim for more binding in the list +-- C-x/v to open the result in split window, o to open and close the list +-- lvim.lsp.buffer_mappings.normal_mode["gd"] = { ":vsplitTrouble lsp_definitions", "Goto Definitions" } +-- lvim.lsp.buffer_mappings.normal_mode["gr"] = { "Trouble lsp_references", "Goto References" } +-- lvim.lsp.buffer_mappings.normal_mode["gR"] = { "Trouble", "Goto Trouble Lsp List" } +-- lvim.lsp.buffer_mappings.normal_mode["gq"] = { "Trouble quickfix", "QuickFix" } +-- lvim.lsp.buffer_mappings.normal_mode["gl"] = { "Trouble loclist", "LocationList" } +-- lvim.lsp.buffer_mappings.normal_mode["gt"] = { "Trouble lsp_type_definitions", "Show Type Definition" } +-- lvim.lsp.buffer_mappings.normal_mode["gD"] = { "Trouble document_diagnostics", "List Document Diagnostics" } +-- lvim.lsp.buffer_mappings.normal_mode["gw"] = { "Trouble workspace_diagnostics", "List Workspace Diagnostics" } + +-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. +-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet. +-- local _, actions = pcall(require, "telescope.actions") +-- lvim.builtin.telescope.defaults.mappings = { +-- -- for input mode +-- i = { +-- [""] = actions.move_selection_next, +-- [""] = actions.move_selection_previous, +-- [""] = actions.cycle_history_next, +-- [""] = actions.cycle_history_prev, +-- }, +-- -- for normal mode +-- n = { +-- [""] = actions.move_selection_next, +-- [""] = actions.move_selection_previous, +-- }, +-- } + +-- User Config for predefined plugins lvim.builtin.terminal.float_opts = { -- bottom-right floating terminal with 50% of the width/height of current vim window width = function(_term) @@ -427,10 +385,8 @@ lvim.builtin.terminal.float_opts = { return height end, } --- disable nvimtree since a bug: LunarVim/issues/2512 -lvim.builtin.nvimtree.active = false --- if you don't want all the parsers change this to a table of the ones you want +-- If you don't want all the parsers change this to a table of the ones you want -- You may need to :TSupdate if vim has tree-sitter issues require("nvim-treesitter.configs").setup({ ensure_installed = { @@ -458,19 +414,6 @@ require("nvim-treesitter.configs").setup({ highlight = { enabled = true }, }) --- generic LSP settings - --- ---@usage disable automatic installation of servers --- lvim.lsp.automatic_servers_installation = false - --- ---@usage Select which servers should be configured manually. Requires `:LvimCacheReset` to take effect. --- See the full default list `:lua print(vim.inspect(lvim.lsp.override))` --- vim.list_extend(lvim.lsp.override, { "pyright" }) - --- ---@usage setup a server -- see: https://www.lunarvim.org/languages/#overriding-the-default-configuration --- local opts = {} -- check the lspconfig documentation for a list of all possible options --- require("lvim.lsp.manager").setup("pylsp", opts) - -- -- you can set a custom on_attach function that will be used for all the language servers -- -- See -- lvim.lsp.on_attach_callback = function(client, bufnr) @@ -481,14 +424,14 @@ require("nvim-treesitter.configs").setup({ -- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- end --- -- set a formatter, this will override the language server formatting capabilities (if it exists) +-- -- linters, formatters and code actions local formatters = require("lvim.lsp.null-ls.formatters") formatters.setup({ - { command = "stylua", filetypes = { "lua" } }, + -- { command = "stylua" }, { command = "fish_indent", filetypes = { "fish" } }, - { command = "shfmt", filetypes = { "sh" } }, - { command = "black", filetypes = { "python" } }, - { command = "isort", filetypes = { "python" } }, + { command = "shfmt", filetypes = { "sh" } }, + { command = "black", filetypes = { "python" } }, + { command = "isort", filetypes = { "python" } }, -- { -- -- each formatter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration -- command = "prettier", @@ -500,7 +443,6 @@ formatters.setup({ -- }, }) --- set additional linters local linters = require("lvim.lsp.null-ls.linters") linters.setup({ { command = "flake8", filetypes = { "python" } }, @@ -517,23 +459,263 @@ linters.setup({ filetypes = { "javascript", "python" }, }, }) +-- local code_actions = require "lvim.lsp.null-ls.code_actions" +-- code_actions.setup { +-- { +-- exe = "eslint", +-- filetypes = { "typescript", "typescriptreact" }, +-- }, +-- } --- set commentstring for some filetypes --- https://github.com/numToStr/Comment.nvim#%EF%B8%8F-filetypes--languages --- dosinit is for files like /etc/pacman.conf and /etc/pacman.d/*list --- "" for files wich filetype is empty -require("Comment.ft")({ "", "gitconfig", "dosini", "org" }, "#%s") +-- Additional Plugins, +lvim.plugins = { + -- {"folke/tokyonight.nvim"}, + { "folke/trouble.nvim", cmd = "TroubleToggle" }, + { "szw/vim-maximizer" }, + { + "brenoprata10/nvim-highlight-colors", + config = true + -- config = function() + -- require("nvim-highlight-colors").setup() + -- end, + }, + { "vimlab/split-term.vim" }, + { "thinca/vim-quickrun" }, + { + "ethanholz/nvim-lastplace", + config = function() + require("nvim-lastplace").setup({ + lastplace_ignore_buftype = { "quickfix", "nofile", "help" }, + -- lastplace_ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }, + lastplace_open_folds = true, + }) + end, + }, + { + "folke/flash.nvim", + config = true + -- config = function() + -- require("flash").setup() + -- end, + }, + { + url = "https://gitlab.com/yorickpeterse/nvim-window.git", + config = function() + -- https://gitlab.com/yorickpeterse/nvim-window.git + require("nvim-window").setup({ + -- The characters available for hinting windows. + chars = { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + }, + -- A group to use for overwriting the Normal highlight group in the floating + -- window. This can be used to change the background color. + normal_hl = "Normal", + -- The highlight group to apply to the line that contains the hint characters. + -- This is used to make them stand out more. + hint_hl = "Bold", + -- The border style to use for the floating window. + border = "single", + }) + end, + }, + { + "theHamsta/nvim-dap-virtual-text", + config = true + -- config = function() + -- require("nvim-dap-virtual-text").setup() + -- end, + }, + { "timonv/vim-cargo" }, + -- ds"(delete "), cs"'(chanage " to '), ysw"(add the next word double ") + { + "kylechui/nvim-surround", + config = function() + require("nvim-surround").setup({ + keymaps = { + -- vim-surround style keymaps + -- insert = "ys", + -- visual = "S", + delete = "ds", + change = "cs", + }, + }) + end, + }, + { + "vigoux/notifier.nvim", + config = true + -- config = function() + -- require'notifier'.setup { + -- -- You configuration here + -- } + -- end + }, + -- { + -- "j-hui/fidget.nvim", + -- version = "legacy", + -- config = true + -- -- config = function() + -- -- require("fidget").setup() + -- -- end, + -- }, + { + "glepnir/lspsaga.nvim", + branch = "main", + config = function() + require("lspsaga").setup({ + finder = { + max_height = 0.6, + force_max_height = true, + }, + }) + end, + dependencies = { + { "nvim-tree/nvim-web-devicons" }, + --Please make sure you install markdown and markdown_inline parser + { "nvim-treesitter/nvim-treesitter" }, + }, + }, + -- FIXME: "[LSP] No client with id 1" msg when opening rust file with lvim + -- https://github.com/LunarVim/LunarVim/discussions/3201 + { + "simrat39/rust-tools.nvim", + config = function() + local status_ok, rust_tools = pcall(require, "rust-tools") + if not status_ok then + return + end + + local opts = { + tools = { + executor = require("rust-tools/executors").termopen, -- can be quickfix or termopen + reload_workspace_from_cargo_toml = true, + inlay_hints = { + auto = true, + only_current_line = false, + show_parameter_hints = true, + parameter_hints_prefix = "<-", + other_hints_prefix = "=>", + max_len_align = false, + max_len_align_padding = 1, + right_align = false, + right_align_padding = 7, + highlight = "Ignore", + }, + hover_actions = { + --border = { + -- { "╭", "FloatBorder" }, + -- { "─", "FloatBorder" }, + -- { "╮", "FloatBorder" }, + -- { "│", "FloatBorder" }, + -- { "╯", "FloatBorder" }, + -- { "─", "FloatBorder" }, + -- { "╰", "FloatBorder" }, + -- { "│", "FloatBorder" }, + --}, + auto_focus = true, + }, + }, + server = { + on_attach = require("lvim.lsp").common_on_attach, + on_init = require("lvim.lsp").common_on_init, + settings = { + ["rust-analyzer"] = { + check = { + command = "clippy", + extraArgs = { "--all", "--", "-W", "clippy::all" }, + }, + }, + }, + }, + } + --local extension_path = vim.fn.expand "~/" .. ".vscode/extensions/vadimcn.vscode-lldb-1.7.3/" + + --local codelldb_path = extension_path .. "adapter/codelldb" + --local liblldb_path = extension_path .. "lldb/lib/liblldb.dylib" --- Autocommands (https://neovim.io/doc/user/autocmd.html) + --opts.dap = { + -- adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path), + --} + rust_tools.setup(opts) + end, + ft = { "rust", "rs" }, + }, + { + "saecki/crates.nvim", + ft = { "rust", "toml" }, + config = true + -- config = function() + -- require("crates").setup() + -- end, + }, + { + "windwp/nvim-spectre", + event = "BufRead", + config = true + -- config = function() + -- require("spectre").setup() + -- end, + }, + { + "HiPhish/rainbow-delimiters.nvim", + }, + { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = {} + } +} -- end of personal plugins + +require("telescope").setup({ + pickers = { + find_files = { + hidden = true, + theme = "ivy", + path_display = { nil }, + }, + }, +}) + +require("cmp").setup({ + sources = { + -- for crates.nvim in Crate.toml file + { name = "crates" }, + }, +}) + +require("indent_blankline").setup({ + space_char_blankline = " ", + show_first_indent_leve = true, + -- NOTE: enabling the following line will cause error msg for empty lvim session + -- show_current_context = true, + show_current_context_start = true, + char_highlight_list = { + "IndentBlanklineIndent1", + }, +}) + +-- -- Autocommands (`:help autocmd`) +-- vim.api.nvim_create_autocmd("FileType", { +-- pattern = "zsh", +-- callback = function() +-- -- let treesitter use bash highlight for zsh files as well +-- require("nvim-treesitter.highlight").attach(0, "bash") +-- end, +-- }) +-- TODO lvim.autocommands = { -- On entering a lua file, set the tab spacing and shift width to 8 { "BufWinEnter", { pattern = { "*.lua" }, command = "set noexpandtab ts=2 sw=2" } }, - { "BufRead,BufNewFile", { pattern = { "*.c", "*.h" }, command = "set noexpandtab tabstop=8 shiftwidth=8" } }, - { - "BufRead,BufNewFile", - { pattern = { "*.cpp", "*.cc", "*.hpp" }, command = "set noexpandtab tabstop=4 shiftwidth=4" }, - }, - { "BufRead,BufNewFile", { pattern = { "*.fish" }, command = "set expandtab tabstop=4 shiftwidth=4" } }, + { "BufEnter", { pattern = { "*.c", "*.h" }, command = "set noexpandtab tabstop=8 shiftwidth=8" } }, + { "BufEnter", { pattern = { "*.cpp", "*.cc", "*.hpp" }, command = "set noexpandtab tabstop=4 shiftwidth=4" } }, + { "BufRead", { pattern = { "*.fish" }, command = "set expandtab tabstop=4 shiftwidth=4" } }, -- auto hover when cursot is stopped at something -- { -- "CursorHold,CursorHoldI,MenuPopup", @@ -541,18 +723,27 @@ lvim.autocommands = { -- }, -- hover can maually triggered by K -- * if &filetype != "latex" && &filetype != "plaintex" | do - { - "CursorHold,CursorHoldI,MenuPopup", - { pattern = { "*" }, command = 'if &ft != "fish" | lua vim.lsp.buf.hover()' }, - }, + --{ + -- "CursorHold,CursorHoldI,MenuPopup", + -- { pattern = { "*" }, command = 'if &ft != "fish" | lua vim.lsp.buf.hover()' }, + --}, -- start insert when editing git commit message - { "FileType", { pattern = { "gitcommit" }, command = "startinsert" } }, + { "FileType", { pattern = { "gitcommit" }, command = "startinsert" } }, -- for color and borders of pop windows likes which-key and lsp { "ColorScheme", { pattern = { "*" }, command = "highlight Pmenu ctermbg=NONE guibg=NONE" } }, { "ColorScheme", { pattern = { "*" }, command = "highlight FloatBorder ctermbg=NONE guibg=NONE" } }, + { "ColorScheme", { pattern = { "*" }, command = "highlight IndentBlanklineIndent1 guifg=gray gui=nocombine" } }, } +-- set commentstring for some filetypes +-- https://github.com/numToStr/Comment.nvim#%EF%B8%8F-filetypes--languages +-- dosinit is for files like /etc/pacman.conf and /etc/pacman.d/*list +-- "" for files wich filetype is empty +require("Comment.ft")({ "", "gitconfig", "dosini", "org" }, "#%s") +require("Comment.ft")({ "kdl" }, "// %s") + -- debugger -- dap +lvim.builtin.dap.active = true require("nvim-dap-virtual-text").setup({ enabled = true, enabled_commands = true, @@ -568,7 +759,7 @@ require("nvim-dap-virtual-text").setup({ -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()` }) -- dapui -require("dapui").setup() +--require("dapui").setup() local dap, dapui = require("dap"), require("dapui") dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open() diff --git a/lunarvim/README.org b/lunarvim/README.org index 1e70d0c5..927e3ee0 100644 --- a/lunarvim/README.org +++ b/lunarvim/README.org @@ -7,5 +7,3 @@ $ bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/master/util $ bash -c "bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/master/utils/installer/install.sh)" # uninstall: $ ~/.local/share/lunarvim/lvim/utils/installer/uninstall.sh -# If lots of errors after reinstall, exucute: -# :LvimCacheReset and :PackerSync