diff --git a/.config/fish/config.fish b/.config/fish/config.fish new file mode 100644 index 0000000..58b4d39 --- /dev/null +++ b/.config/fish/config.fish @@ -0,0 +1,9 @@ +if status is-interactive + +set fish_greeting + +function fish_prompt + printf "%s%s%s 󰘧 " (set_color $fish_color_cwd) (prompt_pwd) (set_color --reset) +end + +end diff --git a/.config/nvim/ftplugin/c.lua b/.config/nvim/ftplugin/c.lua new file mode 100644 index 0000000..b206c11 --- /dev/null +++ b/.config/nvim/ftplugin/c.lua @@ -0,0 +1,3 @@ +vim.opt.expandtab = true +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index a26bc26..0b34d3f 100755 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -2,3 +2,4 @@ require("autocmd") require("config") require("keymap") require("plugins") +require("lsp") diff --git a/.config/nvim/lua/autocmd.lua b/.config/nvim/lua/autocmd.lua index 8a7bb2a..58ccfc3 100644 --- a/.config/nvim/lua/autocmd.lua +++ b/.config/nvim/lua/autocmd.lua @@ -1,16 +1,12 @@ -vim.opt.completeopt = { "menuone", "noselect", "popup" } - -vim.api.nvim_create_autocmd("LspAttach", { - callback = function(ev) - local client = vim.lsp.get_client_by_id(ev.data.client_id) - if client:supports_method("textDocument/completion") then - vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = false }) - end - end, -}) - -vim.api.nvim_create_autocmd('TextYankPost', { +vim.api.nvim_create_autocmd("TextYankPost", { callback = function() vim.highlight.on_yank({ timeout = 170 }) end, }) + +vim.api.nvim_create_autocmd("FileType", { + pattern = "c3", + callback = function() + pcall(function() vim.treesitter.start(0, "c3") end) + end, +}) diff --git a/.config/nvim/lua/config.lua b/.config/nvim/lua/config.lua index b7cf3d4..ef4d47c 100644 --- a/.config/nvim/lua/config.lua +++ b/.config/nvim/lua/config.lua @@ -1,5 +1,3 @@ -vim.cmd.colorscheme "wildcharm" - vim.opt.number = true vim.opt.relativenumber = true vim.opt.cursorline = true @@ -17,7 +15,7 @@ vim.opt.clipboard = "unnamedplus" vim.opt.signcolumn = "yes" vim.opt.langmap="ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ;ABCDEFGHIJKLMNOPQRSTUVWXYZ,фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz" vim.opt.list = true -vim.opt.listchars = "tab:>-,space:·" +vim.opt.listchars = "tab: |" vim.g.mapleader = " " vim.g.maplocalleader = " " diff --git a/.config/nvim/lua/keymap.lua b/.config/nvim/lua/keymap.lua index a5f3224..954460e 100644 --- a/.config/nvim/lua/keymap.lua +++ b/.config/nvim/lua/keymap.lua @@ -3,18 +3,14 @@ vim.api.nvim_set_keymap("n", "f", ":Pick files", {}) vim.api.nvim_set_keymap("n", "b", ":Pick buffers", {}) vim.api.nvim_set_keymap("n", "g", ":Pick grep_live", {}) -vim.keymap.set("i", "", function() - vim.lsp.completion.get() -end) +-- I love go +vim.api.nvim_set_keymap("n", "n", "iif err != nil {\n}O", {}) +vim.api.nvim_set_keymap("i", "n", "if err != nil {\n}O", {}) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, - { desc = 'Show error/diagnostic messages' }) -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, - { desc = 'Go to previous diagnostic' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, - { desc = 'Go to next diagnostic' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, - { desc = 'Open diagnostics list' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show error/diagnostic messages' }) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) vim.api.nvim_create_autocmd('LspAttach', { desc = 'LSP actions', diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua new file mode 100644 index 0000000..bc9c22c --- /dev/null +++ b/.config/nvim/lua/lsp.lua @@ -0,0 +1,15 @@ +vim.lsp.enable("clangd") +vim.lsp.config("clangd", { + cmd = { "clangd", "--header-insertion=never"} +}) + +vim.lsp.enable("gopls") +vim.lsp.enable("zls") + +vim.lsp.enable("c3lsp") +vim.lsp.config("c3lsp", { + cmd = { + "c3lsp", + "--diagnostics-delay", "1000", + } +}) diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 4388ee7..9e8df38 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -1,13 +1,39 @@ vim.pack.add({ - "https://github.com/nvim-mini/mini.nvim", - "https://github.com/neovim/nvim-lspconfig", + "https://github.com/nvim-mini/mini.nvim", + "https://github.com/neovim/nvim-lspconfig", + "https://github.com/rose-pine/neovim.git", + { src = "https://github.com/saghen/blink.cmp.git", version = vim.version.range("^1") }, + "https://github.com/nvim-treesitter/nvim-treesitter.git", }) require("mini.surround").setup() require("mini.files").setup() require("mini.pick").setup() -vim.lsp.enable("clangd") -vim.lsp.config("clangd", { - cmd = { "clangd", "--header-insertion=never"} +require("rose-pine").setup() +vim.cmd("colorscheme rose-pine") + +require('blink.cmp').setup({ + keymap = { preset = 'default' }, + signature = { enabled = true }, + + appearance = { + use_nvim_cmp_as_default = true, + nerd_font_variant = 'mono' + }, + + completion = { + documentation = { auto_show = true, } + }, + + sources = { + default = { 'lsp', 'path', 'snippets', 'buffer' }, + }, +}) + +require('nvim-treesitter').setup({ + ensure_installed = { + "lua", "c", "zig", "python", "rust", "c3" + }, + highlight = { enable = true } }) diff --git a/.config/nvim/nvim-pack-lock.json b/.config/nvim/nvim-pack-lock.json new file mode 100644 index 0000000..922c6fb --- /dev/null +++ b/.config/nvim/nvim-pack-lock.json @@ -0,0 +1,29 @@ +{ + "plugins": { + "blink.cmp": { + "rev": "78336bc89ee5365633bcf754d93df01678b5c08f", + "src": "https://github.com/saghen/blink.cmp.git", + "version": "1.0.0 - 2.0.0" + }, + "mini.nvim": { + "rev": "15abccbe23525ee0502d2efe620c77db00bfb93c", + "src": "https://github.com/nvim-mini/mini.nvim" + }, + "neovim": { + "rev": "ff483051a47e27d84bdef47703538df1ed9f4a47", + "src": "https://github.com/rose-pine/neovim.git" + }, + "nvim-c3": { + "rev": "751ec7188fa2e92518cdcb0186e657aff7202a90", + "src": "https://github.com/ManuLinares/nvim-c3.git" + }, + "nvim-lspconfig": { + "rev": "9573948c38bfabeec353ae7dd7d3ffec4c506a6b", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-treesitter": { + "rev": "4916d6592ede8c07973490d9322f187e07dfefac", + "src": "https://github.com/nvim-treesitter/nvim-treesitter.git" + } + } +} diff --git a/.emacs b/.emacs index 16c606d..4adee80 100644 --- a/.emacs +++ b/.emacs @@ -1,5 +1,6 @@ (setq custom-file "~/.emacs.custom.el") +(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (require 'use-package) (setq @@ -15,7 +16,7 @@ (setq ring-bell-function 'ignore) -(set-face-attribute 'default nil :font "Iosevka-16") +(set-face-attribute 'default nil :font "IosevkaNF-18") (tool-bar-mode -1) (menu-bar-mode -1) @@ -31,33 +32,71 @@ (setq-default tab-width 4) (setq-default indent-tabs-mode nil) -(load-file "~/.emacs.local/simpc-mode.el") -(require 'simpc-mode) -(add-to-list 'auto-mode-alist '("\\.[hc]\\(pp\\)?\\'" . simpc-mode)) +(add-hook 'c-mode-hook + (lambda () + (setq c-basic-offset 2) + (setq tab-width 2) + (setq indent-tabs-mode nil))) (ido-mode 1) (ido-everywhere 1) (use-package smex :init - (smex-initialize) - :bind ("M-x" . smex)) + (smex-initialize)) (use-package kaolin-themes :config (load-theme 'kaolin-bubblegum t)) -(use-package haskell-mode) +(use-package lsp-mode + :config + (setq lsp-headerline-breadcrumb-enable nil)) +(use-package lsp-ui) (use-package company - :ensure t :init (global-company-mode) :config - (setq company-minimum-prefix-length 3) + (setq company-minimum-prefix-length 1 + company-idle-delay 0.0) (global-set-key (kbd "M-") 'company-complete)) -(use-package multiple-cursors - :bind - (("M-n" . mc/mark-next-like-this) - ("M-p" . mc/mark-previous-like-this) - ("C-c C-a" . mc/mark-all-like-this))) +(use-package evil + :init + (setq evil-want-C-u-scroll t) + (setq evil-want-keybinding nil) + (evil-mode)) + +(use-package evil-collection + :after evil + :init + (evil-collection-init)) + +(with-eval-after-load 'evil-maps + (define-key evil-motion-state-map (kbd "SPC") nil)) + +(with-eval-after-load 'company + (define-key company-active-map (kbd "C-y") #'company-complete-selection)) + +(use-package general + :init + (general-evil-setup) + (general-override-mode)) + +(general-create-definer my-leader-def + :states '(normal visual motion emacs) + :keymaps 'override + :prefix "SPC" + :global-prefix "M-SPC") + +(my-leader-def + "f" 'find-file + "b" 'switch-to-buffer + "x" 'smex + "c" 'compile + "j" 'dired-jump) + +(define-key minibuffer-local-map [escape] 'keyboard-escape-quit) + +(use-package haskell-mode) +(use-package go-mode) diff --git a/.emacs.local/simpc-mode.el b/.emacs.local/simpc-mode.el deleted file mode 100644 index f1d1a32..0000000 --- a/.emacs.local/simpc-mode.el +++ /dev/null @@ -1,127 +0,0 @@ -(require 'subr-x) - -(defvar simpc-mode-syntax-table - (let ((table (make-syntax-table))) - ;; C/C++ style comments - (modify-syntax-entry ?/ ". 124b" table) - (modify-syntax-entry ?* ". 23" table) - (modify-syntax-entry ?\n "> b" table) - ;; Preprocessor stuff? - (modify-syntax-entry ?# "." table) - ;; Chars are the same as strings - (modify-syntax-entry ?' "\"" table) - ;; Treat <> as punctuation (needed to highlight C++ keywords - ;; properly in template syntax) - (modify-syntax-entry ?< "." table) - (modify-syntax-entry ?> "." table) - - (modify-syntax-entry ?& "." table) - (modify-syntax-entry ?% "." table) - table)) - -(defun simpc-types () - '("char" "int" "long" "short" "void" "bool" "float" "double" "signed" "unsigned" - "char16_t" "char32_t" "char8_t" - "int8_t" "uint8_t" "int16_t" "uint16_t" "int32_t" "uint32_t" "int64_t" "uint64_t" - "uintptr_t" - "size_t" "ptrdiff_t" - "va_list")) - -(defun simpc-keywords () - '("auto" "break" "case" "const" "continue" "default" "do" - "else" "enum" "extern" "for" "goto" "if" "register" - "return" "sizeof" "static" "struct" "switch" "typedef" - "union" "volatile" "while" "alignas" "alignof" "and" - "and_eq" "asm" "atomic_cancel" "atomic_commit" "atomic_noexcept" "bitand" - "bitor" "catch" "class" "co_await" - "co_return" "co_yield" "compl" "concept" "const_cast" "consteval" "constexpr" - "constinit" "decltype" "delete" "dynamic_cast" "explicit" "export" "false" - "friend" "inline" "mutable" "namespace" "new" "noexcept" "not" "not_eq" - "nullptr" "operator" "or" "or_eq" "private" "protected" "public" "reflexpr" - "reinterpret_cast" "requires" "static_assert" "static_cast" "synchronized" - "template" "this" "thread_local" "throw" "true" "try" "typeid" "typename" - "using" "virtual" "wchar_t" "xor" "xor_eq")) - -(defun simpc-font-lock-keywords () - (list - `("# *\\(warn\\|error\\)" . font-lock-warning-face) - `("# *[#a-zA-Z0-9_]+" . font-lock-preprocessor-face) - `("# *include\\(?:_next\\)?\\s-+\\(\\(<\\|\"\\).*\\(>\\|\"\\)\\)" . (1 font-lock-string-face)) - `("\\(?:enum\\|struct\\)\\s-+\\([a-zA-Z0-9_]+\\)" . (1 font-lock-type-face)) - `(,(regexp-opt (simpc-keywords) 'symbols) . font-lock-keyword-face) - `(,(regexp-opt (simpc-types) 'symbols) . font-lock-type-face))) - -(defun simpc--previous-non-empty-line () - "Returns either NIL when there is no such line or a pair (line . indentation)" - (save-excursion - ;; If you are on the first line, but not at the beginning of buffer (BOB) the `(bobp)` - ;; function does not return `t`. So we have to move to the beginning of the line first. - ;; TODO: feel free to suggest a better approach for checking BOB here. - (move-beginning-of-line nil) - (if (bobp) - ;; If you are standing at the BOB, you by definition don't have a previous non-empty line. - nil - ;; Moving one line backwards because the current line is by definition is not - ;; the previous non-empty line. - (forward-line -1) - ;; Keep moving backwards until we hit BOB or a non-empty line. - (while (and (not (bobp)) - (string-empty-p - (string-trim-right - (thing-at-point 'line t)))) - (forward-line -1)) - - (if (string-empty-p - (string-trim-right - (thing-at-point 'line t))) - ;; If after moving backwards for this long we still look at an empty - ;; line we by definition didn't find the previous non-empty line. - nil - ;; We found the previous non-empty line! - (cons (thing-at-point 'line t) - (current-indentation)))))) - -(defun simpc--desired-indentation () - (let ((prev (simpc--previous-non-empty-line))) - (if (not prev) - (current-indentation) - (let ((indent-len 4) - (cur-line (string-trim-right (thing-at-point 'line t))) - (prev-line (string-trim-right (car prev))) - (prev-indent (cdr prev))) - (cond - ((string-match-p "^\\s-*switch\\s-*(.+)" prev-line) - prev-indent) - ((and (string-suffix-p "{" prev-line) - (string-prefix-p "}" (string-trim-left cur-line))) - prev-indent) - ((string-suffix-p "{" prev-line) - (+ prev-indent indent-len)) - ((string-prefix-p "}" (string-trim-left cur-line)) - (max (- prev-indent indent-len) 0)) - ((string-suffix-p ":" prev-line) - (if (string-suffix-p ":" cur-line) - prev-indent - (+ prev-indent indent-len))) - ((string-suffix-p ":" cur-line) - (max (- prev-indent indent-len) 0)) - (t prev-indent)))))) - -;;; TODO: customizable indentation (amount of spaces, tabs, etc) -(defun simpc-indent-line () - (interactive) - (when (not (bobp)) - (let* ((desired-indentation - (simpc--desired-indentation)) - (n (max (- (current-column) (current-indentation)) 0))) - (indent-line-to desired-indentation) - (forward-char n)))) - -(define-derived-mode simpc-mode prog-mode "Simple C" - "Simple major mode for editing C files." - :syntax-table simpc-mode-syntax-table - (setq-local font-lock-defaults '(simpc-font-lock-keywords)) - (setq-local indent-line-function 'simpc-indent-line) - (setq-local comment-start "// ")) - -(provide 'simpc-mode)