diff --git a/.config/emacs/init.org b/.config/emacs/init.org index bb0cd8f..38cb603 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -1108,7 +1108,6 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i #+begin_src emacs-lisp (straight-use-package 'dap-mode) #+end_src - ** Languages *** Rust #+begin_src emacs-lisp diff --git a/.config/magit/early-init.el b/.config/magit/early-init.el index f4a6336..cb9392b 100644 --- a/.config/magit/early-init.el +++ b/.config/magit/early-init.el @@ -5,7 +5,7 @@ (add-hook 'emacs-startup-hook (lambda () - "Restore defalut values after init." + "Restore defaults values after init." (setq file-name-handler-alist default-file-name-handler-alist) (if (boundp 'after-focus-change-function) (add-function :after after-focus-change-function @@ -27,13 +27,6 @@ (setq load-prefer-newer nil) -(setq safe-local-variable-values - '((org-src-preserve-indentation . t) - (eval add-hook 'after-save-hook - '(lambda nil - (org-babel-tangle)) - nil t))) - (setq default-input-method nil) (setq utf-translate-cjk-mode nil) ; disable CJK coding/encoding (Chinese/Japanese/Korean characters) (set-language-environment 'utf-8) diff --git a/.config/magit/init.el b/.config/magit/init.el index 98db545..a00930c 100644 --- a/.config/magit/init.el +++ b/.config/magit/init.el @@ -53,15 +53,11 @@ (evil-global-set-key 'normal (kbd "C-s") #'save-buffer) (straight-use-package 'all-the-icons-completion) -(straight-use-package '(vertico :files (:defaults "extensions/*") - :includes (vertico-indexed - vertico-repeat - vertico-directory))) +(straight-use-package '(vertico :files (:defaults "extensions/*"))) (vertico-mode) (define-key vertico-map (kbd "C-w") #'vertico-directory-delete-word) -(vertico-indexed-mode) (setq vertico-count 17 vertico-resize nil @@ -72,62 +68,6 @@ (add-hook 'minibuffer-setup-hook #'vertico-repeat-save) (add-to-list 'savehist-additional-variables 'vertico-repeat-history) -(straight-use-package 'vertico-directory) - -(defun embark-which-key-indicator () - "An embark indicator that displays keymaps using which-key. -The which-key help message will show the type and value of the -current target followed by an ellipsis if there are further -targets." - (lambda (&optional keymap targets prefix) - (if (null keymap) - (which-key--hide-popup-ignore-command) - (which-key--show-keymap - (if (eq (plist-get (car targets) :type) 'embark-become) - "Become" - (format "Act on %s '%s'%s" - (plist-get (car targets) :type) - (embark--truncate-target (plist-get (car targets) :target)) - (if (cdr targets) "…" ""))) - (if prefix - (pcase (lookup-key keymap prefix 'accept-default) - ((and (pred keymapp) km) km) - (_ (key-binding prefix 'accept-default))) - keymap) - nil nil t (lambda (binding) - (not (string-suffix-p "-argument" (cdr binding)))))))) - -(setq embark-indicators - '(embark-which-key-indicator - embark-highlight-indicator - embark-isearch-highlight-indicator)) - -(defun embark-hide-which-key-indicator (fn &rest args) - "Hide the which-key indicator immediately when using the completing-read prompter." - (which-key--hide-popup-ignore-command) - (let ((embark-indicators - (remq #'embark-which-key-indicator embark-indicators))) - (apply fn args))) - -(advice-add #'embark-completing-read-prompter - :around #'embark-hide-which-key-indicator) - -(global-set-key (kbd "C-'") #'embark-act) - -(straight-use-package 'embark-consult) - -(straight-use-package 'marginalia) -(setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) -(setq marginalia-align 'right) -(setq marginalia-max-relative-age most-positive-fixnum) -(marginalia-mode) -(define-key minibuffer-local-map (kbd "M-A") #'marginalia-cycle) -(require 'all-the-icons-completion) -(all-the-icons-completion-mode) -(all-the-icons-completion-marginalia-setup) - -(add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup) - (straight-use-package 'orderless) (setq completion-styles '(orderless basic) completion-category-overrides '((file (styles basic partial-completion)))) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 9e34d54..bde45bf 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -4,16 +4,7 @@ local set = vim.opt set.clipboard = 'unnamedplus' set.wrap = false -set.number = true -set.relativenumber = true -set.ignorecase = true -set.smartcase = true -set.termguicolors = true -set.swapfile = false -set.backup = false -set.undodir = os.getenv("XDG_CACHE_HOME") .. "/nvim/undo" -set.undofile = true -set.hlsearch = false +set.number = true set.relativenumber = true set.ignorecase = true set.smartcase = true set.termguicolors = true set.swapfile = false set.backup = false set.undodir = os.getenv("XDG_CACHE_HOME") .. "/nvim/undo" set.undofile = true set.hlsearch = false set.incsearch = true set.cursorline = true set.cmdheight = 0 @@ -40,7 +31,8 @@ map("n", "J", "mzJ`z") map("n", "", vim.cmd.w) map("n", "", vim.cmd.wq) -map("n", "", vim.cmd.source) +map("n", "", vim.cmd.source) +map("n", "", "") map("n", "vv", "^vg_", { noremap = true }) @@ -89,14 +81,4 @@ map('n', '', 'l', {}) -- -- neogit.setup {} -function ToggleInlayHints() - local rt = require("rust-tools") - if _G.inlay_hints_toggle == true then - rt.inlay_hints.enable() - else - rt.inlay_hints.disable() - end - _G.inlay_hints_toggle = not _G.inlay_hints_toggle -end -vim.keymap.set('n', 'li', ':lua ToggleInlayHints()') - +vim.keymap.set("n", "tw", ":set wrap!") diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index bce1062..7cc6d5f 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -30,7 +30,7 @@ packer.init({ packer.startup(function(use) -- Packer can manage itself use 'wbthomason/packer.nvim' - use 'nvim-lua/plenary.nvim' + use 'nvim-lua/plenary.nvim' use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', @@ -50,37 +50,122 @@ packer.startup(function(use) ts_update() end } - use { -- Additional text objects via treesitter + use { 'nvim-treesitter/nvim-treesitter-textobjects', after = 'nvim-treesitter', } - use 'neovim/nvim-lspconfig' use { - 'simrat39/rust-tools.nvim', + 'neovim/nvim-lspconfig', config = function() local rt = require("rust-tools") + local capabilities = require("cmp_nvim_lsp").default_capabilities() + local on_attach = function(_, bufnr) + show_hints = false + + toggle_hints = function() + if show_hints then + rt.inlay_hints.enable() + else + rt.inlay_hints.disable() + end + show_hints = not show_hints + end + vim.diagnostic.config { + float = { border = "rounded" }, + } + vim.keymap.set("n", "ti", toggle_hints) + vim.diagnostic.config({ + virtual_text = true, + signs = true, + underline = true, + update_in_insert = false, + severity_sort = false, + }) + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) + vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'lwa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'lwr', vim.lsp.buf.remove_workspace_folder, bufopts) + local ws_folders = function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end + vim.keymap.set('n', 'lwl', ws_folders, bufopts) + vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'lr', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'la', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'lf', function() vim.lsp.buf.format { async = true } end, bufopts) + + vim.keymap.set('n', 'ee', vim.diagnostic.open_float, opts) + vim.keymap.set('n', '', vim.diagnostic.goto_prev, opts) + vim.keymap.set('n', '', vim.diagnostic.goto_next, opts) + end rt.setup({ server = { - on_attach = function(_, bufnr) - -- Hover actions - vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) - -- Code action groups - vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) - end, + on_attach = on_attach, + capabilities = capabilities }, }) end } + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/cmp-path' + use 'hrsh7th/cmp-cmdline' + use { + 'hrsh7th/nvim-cmp', + config = function() + local cmp = require('cmp') + cmp.setup({ + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + completion = { + autocomplete = false + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'buffer' }, + { name = 'path' }, + }), + experimental = { + ghost_text = true, + }, + }) + vim.keymap.set('i', '', cmp.complete) + end + } + use { + 'simrat39/rust-tools.nvim' + } use { 'WhoIsSethDaniel/toggle-lsp-diagnostics.nvim', config = function() require'toggle_lsp_diagnostics'.init() - vim.keymap.set('n', 'e', vim.cmd.ToggleDiag) + vim.keymap.set('n', 'te', vim.cmd.ToggleDiag) end } use { - 'nvim-telescope/telescope.nvim', tag = '0.1.0', - requires = { {'nvim-lua/plenary.nvim'} } + 'j-hui/fidget.nvim', + after = 'rust-tools.nvim', + config = function() + require("fidget").setup({}) + end } use 'mfussenegger/nvim-dap' use { @@ -91,6 +176,10 @@ packer.startup(function(use) end, } use 'mbbill/undotree' + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.0', + requires = { {'nvim-lua/plenary.nvim'} } + } use { 'numToStr/Comment.nvim', config = function() @@ -220,56 +309,3 @@ dap.configurations.rust = { dap.configurations.c = dap.configurations.rust dap.configurations.cpp = dap.configurations.rust - -local on_attach = function(client, bufnr) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - vim.diagnostic.config({ - virtual_text = true, - signs = true, - underline = true, - update_in_insert = false, - severity_sort = false, - }) - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap=true, silent=true, buffer=bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set('n', 'wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) -end - -require('lspconfig')['rust_analyzer'].setup{ - on_attach = on_attach, - flags = lsp_flags, - settings = { - ["rust-analyzer"] = {} - } -} -local hints = false - -show_hints = false - -toggle_hints = function() - local hints = require("rust-tools").inlay_hints - if show_hints then - hints.enable() - else - hints.disable() - end - show_hints = not show_hints -end - -vim.keymap.set("n", "li", toggle_hints) diff --git a/.config/nvim/lua/rust.lua b/.config/nvim/lua/rust.lua new file mode 100644 index 0000000..43ae145 --- /dev/null +++ b/.config/nvim/lua/rust.lua @@ -0,0 +1,4 @@ + +return function rust() + +end