diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 1694204..4c60c50 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -17,3 +17,6 @@ require("plugin.cmp") -- ./lua/plugin/cmp.lua -- treesitter require("plugin.treesitter") -- ./lua/plugin/treesitter.lua + +-- commenting, done right +require("plugin.comment") -- ./lua/plugin/comment.lua diff --git a/.config/nvim/lua/lsp/c.lua b/.config/nvim/lua/lsp/c.lua index e9277c0..986eca3 100644 --- a/.config/nvim/lua/lsp/c.lua +++ b/.config/nvim/lua/lsp/c.lua @@ -3,11 +3,18 @@ -- License : GPLv3 -- Description : clangd config file for lsp +-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers.. +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + + require("lspconfig").clangd.setup { cmd = { "clangd", "--background-index", "--suggest-missing-includes", "--clang-tidy", "--header-insertion=iwyu" - } + }, + -- The following example advertise capabilities to `clangd`. + capabilities = capabilities, } diff --git a/.config/nvim/lua/lsp/init.lua b/.config/nvim/lua/lsp/init.lua index 7dd9e93..8d12035 100644 --- a/.config/nvim/lua/lsp/init.lua +++ b/.config/nvim/lua/lsp/init.lua @@ -3,7 +3,7 @@ -- License : GPLv3 -- Description : neovim lsp config file -local lsp = {} +local M = {} vim.fn.sign_define( "DiagnosticSignError", @@ -38,39 +38,43 @@ vim.fn.sign_define( } ) --- symbols for autocomplete -vim.lsp.protocol.CompletionItemKind = { - "  ", -- 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 +M.icons = { + Class = "  ", + Color = "  ", + Constant = " µ ", + Constructor = "  ", + Enum = "  ", + EnumMember = "  ", + Event = "  ", + Field = "  ", + File = "  ", + Folder = "  ", + Function = "  ", + Keyword = "  ", + Interface = "  ", + Method = "  ", + Module = "  ", + Operator = "  ", + Property = "  ", + Reference = "  ", + Snippet = "  ", + Struct = "  ", + Text = "  ", + TypeParameter = "  ", + Unit = "  ", + Value = "  ", + Variable = "  ", } -function lsp.setup() +function M.setup() + local kinds = vim.lsp.protocol.CompletionItemKind + for i, kind in ipairs(kinds) do + kinds[i] = M.icons[kind] or kind + end + local ft = vim.bo.filetype if ft == "cpp" then ft = "c" end require("lsp." .. ft) -- ./.lua end -return lsp +return M diff --git a/.config/nvim/lua/lsp/lua.lua b/.config/nvim/lua/lsp/lua.lua index 11567ec..892afc2 100644 --- a/.config/nvim/lua/lsp/lua.lua +++ b/.config/nvim/lua/lsp/lua.lua @@ -21,7 +21,7 @@ require'lspconfig'.sumneko_lua.setup { }, diagnostics = { -- Get the language server to recognize the `vim` global - globals = {'vim'}, + globals = {"vim", "use", "globals", "utils"}, }, workspace = { -- Make the server aware of Neovim runtime files diff --git a/.config/nvim/lua/plugin/cmp.lua b/.config/nvim/lua/plugin/cmp.lua index deebb51..fee7dda 100644 --- a/.config/nvim/lua/plugin/cmp.lua +++ b/.config/nvim/lua/plugin/cmp.lua @@ -58,8 +58,8 @@ cmp.setup { select = true, }), [""] = cmp.mapping(function(fallback) - if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(t "", "n") + if cmp.visible() then + cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() elseif check_backspace() then @@ -69,8 +69,8 @@ cmp.setup { end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) - if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(t "", "n") + if cmp.visible() then + cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else diff --git a/.config/nvim/lua/plugin/comment.lua b/.config/nvim/lua/plugin/comment.lua new file mode 100644 index 0000000..6cb9912 --- /dev/null +++ b/.config/nvim/lua/plugin/comment.lua @@ -0,0 +1,54 @@ +-- Author : swytch +-- Created : Tuesday Oct. 12, 2021 19:07:36 CET +-- License : GPLv3 +-- Description : Comment plugin config file + +require("Comment").setup { + ---Add a space b/w comment and the line + ---@type boolean + padding = true, + + ---Lines to be ignored while comment/uncomment. + ---Could be a regex string or a function that returns a regex string. + ---Example: Use '^$' to ignore empty lines + ---@type string|function + ignore = nil, + + ---Whether to create basic (operator-pending) and extra mappings for NORMAL/VISUAL mode + ---@type table + mappings = { + ---operator-pending mapping + ---Includes `gcc`, `gcb`, `gc[count]{motion}` and `gb[count]{motion}` + basic = true, + ---extended mapping + ---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}` + extra = false, + }, + + ---LHS of line and block comment toggle mapping in NORMAL/VISUAL mode + ---@type table + toggler = { + ---line-comment toggle + line = 'gcc', + ---block-comment toggle + block = 'gbc', + }, + + ---LHS of line and block comment operator-mode mapping in NORMAL/VISUAL mode + ---@type table + opleader = { + ---line-comment opfunc mapping + line = 'gc', + ---block-comment opfunc mapping + block = 'gb', + }, + + ---Pre-hook, called before commenting the line + ---@type function|nil + pre_hook = nil, + + ---Post-hook, called after commenting is done + ---@type function|nil + post_hook = nil, +} + diff --git a/.config/nvim/lua/plugin/treesitter.lua b/.config/nvim/lua/plugin/treesitter.lua index 8133cfe..e294959 100644 --- a/.config/nvim/lua/plugin/treesitter.lua +++ b/.config/nvim/lua/plugin/treesitter.lua @@ -1,3 +1,8 @@ +-- Author : swytch +-- Created : Monday May 24, 2021 20:02:19 CET +-- License : GPLv3 +-- Description : treesitter config file + require("nvim-treesitter.configs").setup { ensure_installed = { "c", "lua", "python", "bash" }, ignore_install = { "javascript" }, diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index e002111..dffc26d 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -69,6 +69,9 @@ return require("packer").startup(function() } } + -- commenting, simplified + use "numToStr/Comment.nvim" + -- display colors directly in editor use { "norcalli/nvim-colorizer.lua", diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile index 043d577..e8160f0 100644 --- a/.config/zsh/.zprofile +++ b/.config/zsh/.zprofile @@ -19,6 +19,8 @@ export ANDROID_PREFS_ROOT="$XDG_CONFIG_HOME/android" export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" export TEXMFHOME="$XDG_DATA_HOME/texmf" export CARGO_HOME="$XDG_DATA_HOME/cargo" +export OPAMROOT="$XDG_DATA_HOME/opam" +export COQBIN="$OPAMROOT/default/bin" ## default programs export SUDO_ASKPASS="$HOME/.local/bin/dmenupass" diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 277119e..7588c43 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -78,3 +78,6 @@ typeset -A ZSH_HIGHLIGHT_STYLES ZSH_HIGHLIGHT_STYLES[alias]='fg=green,bold' ZSH_HIGHLIGHT_STYLES[path]='fg=magenta,bold' ZSH_HIGHLIGHT_STYLES[unknown-token]='bg=red,fg=white,bold' + +# opam configuration +test -r "$OPAMROOT/opam-init/init.zsh" && . "$OPAMROOT/opam-init/init.zsh" > /dev/null 2> /dev/null || true