diff --git a/.config/ambit/config.ambit b/.config/ambit/config.ambit index 9d2c0f9..253a7d0 100644 --- a/.config/ambit/config.ambit +++ b/.config/ambit/config.ambit @@ -1,11 +1,12 @@ .config/ambit/config.ambit; .config/nvim/[ - init.vim, - startscreen.vimstart, - UltiSnips/[ - cpp.snippets, - markdown.snippets, - tex.snippets + init.lua, + lua/[ + completion.lua, + lsp.lua, + mappings.lua, + plugins.lua, + treesitter.lua ] ]; .config/eww/[ diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..ee63e88 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,35 @@ +-- https://github.com/priime0/dotfiles + +-- given a key and value, set nvim's global settings of key to value +local function opt(key, value) + vim.o[key] = value +end + +-- line numbers +opt("number", true) +opt("relativenumber", true) + +-- tabs +opt("expandtab", true) +opt("tabstop", 4) +opt("shiftwidth", 4) +opt("smarttab", true) + +-- indentation +opt("smartindent", true) +opt("autoindent", true) + +-- misc +opt("termguicolors", true) +opt("scrolloff", 1) +opt("cursorline", true) +opt("showcmd", true) +opt("inccommand", "split") +opt("updatetime", 100) +opt("mouse", "a") + +require("plugins") +require("mappings") +require("treesitter") +require("lsp") +require("completion") diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 7c9f4c8..6cb5abb 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -56,6 +56,7 @@ nnoremap b :lua require"gitsigns".blame_line() call plug#begin('~/.config/nvim/plugged') +Plug 'wbthomason/packer.nvim' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'ayu-theme/ayu-vim' Plug 'lewis6991/gitsigns.nvim', {'branch': 'main'} @@ -156,10 +157,6 @@ require'lspconfig'.ccls.setup{ } EOF -lua << EOF -require'lspconfig'.pyls.setup{} -EOF - lua << EOF require'lspconfig'.tsserver.setup{} EOF diff --git a/.config/nvim/lua/completion.lua b/.config/nvim/lua/completion.lua new file mode 100644 index 0000000..2bc4326 --- /dev/null +++ b/.config/nvim/lua/completion.lua @@ -0,0 +1,31 @@ +-- nvim-cmp +local cmp = require("cmp") + +cmp.setup { + completion = { + autocomplete = false + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = 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 = "nvim_lua" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" } + } +} diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua new file mode 100644 index 0000000..e172ecd --- /dev/null +++ b/.config/nvim/lua/lsp.lua @@ -0,0 +1,70 @@ +local lspconfig = require('lspconfig') + +local opts = { noremap = true, silent = true } + +local on_attach = function(client, bufnr) + -- Enable completion + vim.api.nvim_buf_set_option(bufnr, 'omnifunc') + + -- Mappings + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) +end + +local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) + +lspconfig.ccls.setup { + on_attach = on_attach, + capabilities = capabilities, + init_options = { + cache = { + directory = vim.fn.expand("$HOME/.cache/ccls/") + } + } +} + +lspconfig.rust_analyzer.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + ["rust-analyzer"] = { + checkOnSave = { + command = "clippy" + }, + diagnostics = { + disabled = { + "mismatched-arg-count" + } + } + } + } +} + +lspconfig.tsserver.setup { + on_attach = on_attach, + capabilities = capabilities +} + +lspconfig.java_language_server.setup { + on_attach = on_attach, + capabilities = capabilities, + cmd = { "/usr/share/java/java-language-server/lang_server_linux.sh" } +} + +lspconfig.vuels.setup { + on_attach = on_attach, + capabilities = capabilities +} + +lspconfig.racket_langserver.setup {} diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..442bf47 --- /dev/null +++ b/.config/nvim/lua/mappings.lua @@ -0,0 +1 @@ +vim.g.mapleader = "" diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..777dd51 --- /dev/null +++ b/.config/nvim/lua/plugins.lua @@ -0,0 +1,110 @@ +local packer = require("packer") +local use = packer.use + +packer.startup(function() + -- plugin/package manager + use("wbthomason/packer.nvim") + + -- lib + use("nvim-lua/plenary.nvim") + + -- language + use("nvim-treesitter/nvim-treesitter") + use("neovim/nvim-lspconfig") + use("j-hui/fidget.nvim") + + -- ui + use("ayu-theme/ayu-vim") + use("nvim-lua/popup.nvim") + use("nvim-telescope/telescope.nvim") + use("lewis6991/gitsigns.nvim") + use("kyazdani42/nvim-web-devicons") + use("kyazdani42/nvim-tree.lua") + use("nvim-lualine/lualine.nvim") + use("akinsho/toggleterm.nvim") + + -- completion + use("hrsh7th/nvim-cmp") + use("hrsh7th/cmp-path") + use("hrsh7th/cmp-buffer") + use("hrsh7th/cmp-nvim-lsp") + use("hrsh7th/cmp-nvim-lua") + use("L3MON4D3/LuaSnip") + use("saadparwaiz1/cmp_luasnip") + + if packer_bootstrap then + require('packer').sync() + end +end) + +-- fidget +require("fidget").setup {} + +-- ayu +vim.cmd([[let ayucolor="dark"]]) +vim.cmd([[colorscheme ayu]]) + +-- telescope +require("telescope").setup { + defaults = { + mappings = { + i = { + [""] = require("telescope.actions").close + }, + }, + pickers = { + hidden = true, + file_ignore_patterns = { ".git/" } + } + } +} + +-- git signs +require('gitsigns').setup { + signs = { + add = {hl = 'GitSignsAdd' , text = '│', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, + change = {hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + delete = {hl = 'GitSignsDelete', text = '│', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + topdelete = {hl = 'GitSignsDelete', text = '│', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + changedelete = {hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + }, + signcolumn = true, + numhl = false, + linehl = false, + word_diff = false, + watch_gitdir = { + interval = 1500, + follow_files = true + }, +} + +-- nvim-web-devicons +require('nvim-web-devicons').setup {} + +-- nvim-tree +require('nvim-tree').setup { + view = { + width = 25, + signcolumn = "no", + }, + diagnostics = { + enable = true, + }, + git = { + enable = true, + ignore = true, + timeout = 1500, + } +} + +-- lualine +require('lualine').setup { + options = { + theme = 'ayu_dark' + }, +} + +-- toggleterm +require('toggleterm').setup { + open_mapping = [[ot]] +} diff --git a/.config/nvim/lua/treesitter.lua b/.config/nvim/lua/treesitter.lua new file mode 100644 index 0000000..59fd7cf --- /dev/null +++ b/.config/nvim/lua/treesitter.lua @@ -0,0 +1,35 @@ +local ts_config = require("nvim-treesitter.configs") + +ts_config.setup { + ensure_installed = { + "bash", + "c", + "cpp", + "css", + "haskell", + "html", + "java", + "javascript", + "json", + "latex", + "lua", + "make", + "markdown", + "ocaml", + "python", + "regex", + "rust", + "scss", + "svelte", + "toml", + "tsx", + "typescript", + "vim", + "vue", + "yaml" + }, + highlight = { + enable = true, + use_languagetree = true + } +} diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index fce9346..57e3ec0 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -204,3 +204,7 @@ XF86AudioMute super + {a,o} pactl set-sink-volume @DEFAULT_SINK@ {+,-}2% + +# switch monitor mode +super + {x,b} + ~/.screenlayout/{monitor,single-screen}.sh