From d2193c1bd22ba52fc4784eb271b40d71cb140738 Mon Sep 17 00:00:00 2001 From: justanothercatgirl Date: Sat, 9 Dec 2023 21:38:14 +0300 Subject: Added autocopmletion Now settings for every language are in directoty ~/.config/nvim/lua/user/lsp --- .bashrc | 2 +- .config/i3/config | 5 +-- .config/nvim/init.lua | 5 ++- .config/nvim/lazy-lock.json | 20 +++++++-- .config/nvim/lua/user/beautiful.lua | 8 +++- .config/nvim/lua/user/lsp/bash.lua | 1 + .config/nvim/lua/user/lsp/common.lua | 81 +++++++++++++++++++++++++++++++++++ .config/nvim/lua/user/lsp/cxx.lua | 1 + .config/nvim/lua/user/lsp/haskell.lua | 1 + .config/nvim/lua/user/lsp/lua.lua | 1 + .config/nvim/lua/user/lsp/python.lua | 1 + .config/nvim/lua/user/lsp/rust.lua | 26 +++++++++++ .config/nvim/lua/user/lspinit.lua | 10 +++++ .config/nvim/lua/user/options.lua | 7 ++- .config/nvim/lua/user/plugins.lua | 44 ++++++++++++++----- .config/nvim/lua/user/remaps.lua | 6 ++- 16 files changed, 195 insertions(+), 24 deletions(-) create mode 100644 .config/nvim/lua/user/lsp/bash.lua create mode 100644 .config/nvim/lua/user/lsp/common.lua create mode 100644 .config/nvim/lua/user/lsp/cxx.lua create mode 100644 .config/nvim/lua/user/lsp/haskell.lua create mode 100644 .config/nvim/lua/user/lsp/lua.lua create mode 100644 .config/nvim/lua/user/lsp/python.lua create mode 100644 .config/nvim/lua/user/lsp/rust.lua create mode 100644 .config/nvim/lua/user/lspinit.lua diff --git a/.bashrc b/.bashrc index 030cf87..6d68740 100644 --- a/.bashrc +++ b/.bashrc @@ -2,7 +2,7 @@ source ~/.cursed_bash.sh # application shortcuts alias ls="ls --color" -alias dl="bash download.sh" +alias dl="~/.local/bin/download" alias qmake="/usr/lib/qt6/bin/qmake" alias psiphon="psiphon-console-client" alias cppreference="microsoft-edge-dev /usr/share/doc/cppreference/en/cpp.html" diff --git a/.config/i3/config b/.config/i3/config index ab35539..7b7bac3 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -25,7 +25,6 @@ exec_always --no-startup-id devilspie -a # Use pactl to adjust volume in PulseAudio. set $refresh_i3status killall -SIGUSR1 i3status -#set $refresh_i3status killall -SIGUSR1 xmobar bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +1% && $refresh_i3status bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -1% && $refresh_i3status bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status @@ -56,8 +55,8 @@ bindsym $mod+Shift+d exec --no-startup-id dmenu_run # change focus bindsym $mod+j focus left -bindsym $mod+k focus down -bindsym $mod+l focus up +bindsym $mod+k focus up +bindsym $mod+l focus down bindsym $mod+semicolon focus right #screenshots diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 6eafd2c..f372955 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,4 +1,5 @@ +require "user.beautiful" require "user.options" -require "user.remaps" require "user.plugins" -require "user.beautiful" +require "user.remaps" +require "user.lspinit" diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index b672205..f5311ec 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,10 +1,24 @@ { + "LuaSnip": { "branch": "master", "commit": "954c81b53989097faaff0fabc11c29575288c3e1" }, "awesome-vim-colorschemes": { "branch": "master", "commit": "4b2787b8894c4a70c42d15c2808d7cf278cb6abb" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "colorschemes": { "branch": "master", "commit": "e29f32990d6e2c7c3a4763326194fbd847b49dac" }, + "crates.nvim": { "branch": "main", "commit": "b8ea20fda2e1029fbbb1bae7a9eab35c84037ca0" }, + "friendly-snippets": { "branch": "main", "commit": "53d3df271d031c405255e99410628c26a8f0d2b0" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, - "nerdtree": { "branch": "master", "commit": "0cb04e9245b000daf32f04aae5f606011a6aa3b5" }, - "nvim-treesitter": { "branch": "master", "commit": "d8a71826a20dfc9ed3d8a43e28a00611a302b456" }, - "plenary.nvim": { "branch": "master", "commit": "366b0837486f60ae0e7550c15de8ff66d057c4cd" }, + "nerdtree": { "branch": "master", "commit": "9ec27d45a863aeb82fea56cebcb8a75a4e369fc9" }, + "nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" }, + "nvim-lspconfig": { "branch": "master", "commit": "511609ae0311abfcfaed3c398429a147e895ce2c" }, + "nvim-treesitter": { "branch": "master", "commit": "1b5bbb54b385c4eae217113f72df5284bc3cc94b" }, + "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, + "tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" }, "vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } diff --git a/.config/nvim/lua/user/beautiful.lua b/.config/nvim/lua/user/beautiful.lua index 17b7ed5..6af5f98 100644 --- a/.config/nvim/lua/user/beautiful.lua +++ b/.config/nvim/lua/user/beautiful.lua @@ -1,6 +1,12 @@ -- this file contains configuration for colorschemes e.t.c +vim.cmd("colorscheme default") + local colorscheme = "habamax" -- local colorscheme = "evening" -vim.cmd("colo " .. colorscheme) +local status, _retval = pcall(vim.cmd, "colo " .. colorscheme) +if not status then + vim.notify("Error: colorscheme \"" .. colorscheme .. "\" not found!") + return -- what the fuck lua where does this return lmao +end diff --git a/.config/nvim/lua/user/lsp/bash.lua b/.config/nvim/lua/user/lsp/bash.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/bash.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/common.lua b/.config/nvim/lua/user/lsp/common.lua new file mode 100644 index 0000000..032cb7f --- /dev/null +++ b/.config/nvim/lua/user/lsp/common.lua @@ -0,0 +1,81 @@ +-- this file contains setup for snippets and common LSP options + +local cmp_status, cmp = pcall(require, 'cmp') +-- vim.api.nvim_echo({{"Hello!", "Normal"}}, true, {}) +if not cmp_status then + vim.api.nvim_err_writeln(string.format("shit! error status: %s", cmp_status)) + return +end +luasnip = require 'luasnip' +luasnip.setup() + +local expnoresilent = {expr = true, noremap = true, silent = true} +local noresilent = {noremap = true, silent = true} + +-- stolen from https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance +local kind_icons = { + Text = "", Method = "󰆧", + Function = "󰊕", Constructor = "", + Field = "󰇽", Variable = "󰂡", + Class = "󰠱", Interface = "", + Module = "", Property = "󰜢", + Unit = "", Value = "󰎠", + Enum = "", Keyword = "󰌋", + Snippet = "", Color = "󰏘", + File = "󰈙", Reference = "", + Folder = "󰉋", EnumMember = "", + Constant = "󰏿", Struct = "", + Event = "", Operator = "󰆕", + TypeParameter = "󰅲", +} + +-- from https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip +local stolen_function = function() -- to check whether there are words before cursor + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +-- TODO: Finish +cmp.setup { + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- for vsnip (i left it) + luasnip.lsp_expand(args.body) -- for luasnip cause i like it more + end, + }, + -- NOTE: ordering or this table affects completions ordering + sources = { -- TODO: Add keyword_length to some of them ?????? + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'path' }, + { name = 'calc' }, + { name = 'nvim_lua' }, + { name = 'nvim_lsp_signature_help' }, + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + -- the function is also half-stolen + format = function(entry, vim_item) + vim_item.kind = string.format("%s · |%s|", kind_icons[vim_item.kind], vim_item.kind) + vim_item.menu = ({ + buffer = "[Buffer]", + nvim_lsp = "[Lsp]", + vsnip = "[Vsnip]", + luasnip = "[Luasnip]", + path = "[Path]", + nvim_lua = "[Lua]", + calc = "[󰊕(x)dx]", + nvim_lsp_signature_help = "[Lsp-help]", + })[entry.source.name] + return vim_item + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + experimental = { ghost_text = true }, +} + diff --git a/.config/nvim/lua/user/lsp/cxx.lua b/.config/nvim/lua/user/lsp/cxx.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/cxx.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/haskell.lua b/.config/nvim/lua/user/lsp/haskell.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/haskell.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/lua.lua b/.config/nvim/lua/user/lsp/lua.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/lua.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/python.lua b/.config/nvim/lua/user/lsp/python.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/python.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/rust.lua b/.config/nvim/lua/user/lsp/rust.lua new file mode 100644 index 0000000..cfc5c2a --- /dev/null +++ b/.config/nvim/lua/user/lsp/rust.lua @@ -0,0 +1,26 @@ +lsp = require 'lspconfig' + +vim.cmd [[ + autocmd FileType rust highlight link rustLifetime SpecialComment +]] + +vim.cmd [[ + autocmd FileType rust setlocal inccommand=nosplit +]] + +lsp.rust_analyzer.setup{ + cmd = {"rust-analyzer"}, + filetypes = {"rust", "rs"}, + root_dir = lsp.util.root_pattern("Cargo.toml"), + -- fucking magic + capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), + settings = { + ["rust-analyzer"] = { + disgnostics = { enable = false }, + inlayHints = { typeHints = true }, + }, + }, +} + + + diff --git a/.config/nvim/lua/user/lspinit.lua b/.config/nvim/lua/user/lspinit.lua new file mode 100644 index 0000000..38b8eb0 --- /dev/null +++ b/.config/nvim/lua/user/lspinit.lua @@ -0,0 +1,10 @@ +require 'user.lsp.common' +require 'user.lsp.haskell' +require 'user.lsp.python' +require 'user.lsp.bash' +require 'user.lsp.rust' +require 'user.lsp.cxx' +require 'user.lsp.lua' + +-- lsp = require 'lspconfig' + diff --git a/.config/nvim/lua/user/options.lua b/.config/nvim/lua/user/options.lua index a8e58bc..44c3599 100644 --- a/.config/nvim/lua/user/options.lua +++ b/.config/nvim/lua/user/options.lua @@ -16,8 +16,9 @@ local options = { shiftwidth = 8, smartindent = true, swapfile = false, - timeoutlen = 1000, --ms - updatetime = 300, + timeoutlen = 1000, --ms + termguicolors = true, + updatetime = 300, --ms writebackup = false, expandtab = false, -- !!!!!!!!! cursorline = false, @@ -26,6 +27,8 @@ local options = { -- splitting splitbelow = true, splitright = true, + -- autocompletion + completeopt = { 'menuone', 'noselect', 'noinsert' } } for key, val in pairs(options) do diff --git a/.config/nvim/lua/user/plugins.lua b/.config/nvim/lua/user/plugins.lua index ee7dea7..2e52200 100644 --- a/.config/nvim/lua/user/plugins.lua +++ b/.config/nvim/lua/user/plugins.lua @@ -1,17 +1,41 @@ -- this file contains plugin settings as well as initialization of lazy.nvim - -- plugins to be installed plugins = { - "folke/lazy.nvim", -- plugin manager - "nvim-lua/popup.nvim", -- some functions for other plugins - "nvim-lua/plenary.nvim", -- some functions for other plugins - "folke/which-key.nvim", -- pretty self-descriptive name - "rafi/awesome-vim-colorschemes", -- same here - "tpope/vim-commentary", -- gc & gcc for commenting - "tpope/vim-surround", -- replace quotes e.t.c - "nvim-treesitter/nvim-treesitter", -- folding code, advanced syntax highlighting & sitting on a tree - "preservim/nerdtree", -- file explorer + { "folke/lazy.nvim" }, -- plugin manager + -- "williamboman/mason.nvim", -- plugin manager for LSP + -- "williamboman/mason-lspconfig.nvim", -- mason add-ons for lspconfig + + { "nvim-lua/popup.nvim" }, -- some functions for other plugins + { "nvim-lua/plenary.nvim" }, -- some functions for other plugins + { "folke/which-key.nvim" }, -- pretty self-descriptive name + + { "rafi/awesome-vim-colorschemes" }, -- colorschemes + { "lunarvim/colorschemes" }, -- colorschemes + { "folke/tokyonight.nvim" }, -- colorschemes + + { "tpope/vim-commentary" }, -- gc & gcc for commenting + { "tpope/vim-surround" }, -- replace quotes e.t.c + { "preservim/nerdtree" }, -- file explorer + + { "nvim-treesitter/nvim-treesitter" }, -- folding code, advanced syntax highlighting & sitting on a tree + { "neovim/nvim-lspconfig" }, -- LSP configuration + + -- { "hrsh7th/vim-vsnip" }, -- snippet engine + { "L3MON4D3/LuaSnip" }, -- better snippet engine + { "saadparwaiz1/cmp_luasnip" }, -- for luasnip + { "rafamadriz/friendly-snippets" }, -- predefined snippets + + -- Autocompletion framework + { "hrsh7th/nvim-cmp" }, -- the framework + { "hrsh7th/cmp-nvim-lua" }, -- lua config + { "hrsh7th/cmp-nvim-lsp-signature-help" }, -- ?????????? a monster + { "hrsh7th/cmp-nvim-lsp" }, -- LSP completion + { "hrsh7th/cmp-path" }, -- /mnt/D/media/audio_sync/term_download_mp3/HELLO_I_AM_EMU_OTORI.mp3 + { "hrsh7th/cmp-buffer" }, -- current buffer + { "hrsh7th/cmp-cmdline" }, -- command line tools + { "Saecki/crates.nvim" }, -- rust packages from crates.io + } -- options for lazy diff --git a/.config/nvim/lua/user/remaps.lua b/.config/nvim/lua/user/remaps.lua index a047392..e5a465c 100644 --- a/.config/nvim/lua/user/remaps.lua +++ b/.config/nvim/lua/user/remaps.lua @@ -14,6 +14,8 @@ map("n", "j", "", opt) map("n", "k", "", opt) map("n", "dj", "d", opt) map("n", "dk", "d", opt) +map("v", "j", "", opt) +map("v", "k", "", opt) -- window navigation map("n", "", "k", opt) -- SWITCHED K AND J @@ -30,9 +32,9 @@ map("i", "", "", opt) map("i", "", "", opt) -- SWITCHED K AND J map("i", "", "", opt) -- SWITCHED K AND J map("i", "", "", opt) -map("i", "", "", opt) +map("i", "", "wi", opt) map("i", "", "Wi", opt) -map("i", "", "", opt) +map("i", "", "bi", opt) map("i", "", "Bi", opt) -- Terminal mode -- cgit v1.2.3-70-g09d2