diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3d0f56a --- /dev/null +++ b/init.lua @@ -0,0 +1,234 @@ + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +vim.g.mapleader = "\\" -- Make sure to set `mapleader` before lazy so your mappings are correct + + +require("lazy").setup({ + { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + opts = { + theme = "onedark", + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + }, + { + "folke/neoconf.nvim", + cmd = "Neoconf" + }, + "folke/neodev.nvim", + { + "nvim-telescope/telescope.nvim", + tag = '0.1.3', + dependencies = { 'nvim-lua/plenary.nvim' }, + }, + "ludovicchabant/vim-gutentags", + "flazz/vim-colorschemes", + "neovim/nvim-lspconfig", + { + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" } + }, + "neovim/nvim-lspconfig", + --"kien/ctrlp.vim", + { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup() + end, + event = {"CmdlineEnter"}, + ft = {"go", 'gomod'}, + build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries + }, + "navarasu/onedark.nvim", + "deoplete-plugins/deoplete-clang", + "neovim/nvim-lsp", + "robert-oleynik/clangd-nvim", + "tpope/vim-surround", + "scrooloose/nerdcommenter", +}) + +require("telescope").setup { + extensions = { + file_browser = { + theme = "onedark", + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = true, + }, + }, +} +-- require("telescope").setup({ + -- extensions = { + -- lazy = { + -- -- Optional theme (the extension doesn't set a default theme) + -- theme = "ivy", + -- -- Whether or not to show the icon in the first column + -- show_icon = true, + -- -- Mappings for the actions + -- mappings = { + -- open_in_browser = "", + -- open_in_file_browser = "nn", + -- open_in_find_files = "f", + -- open_in_live_grep = "", + -- open_plugins_picker = "", -- Works only after having called first another action + -- open_lazy_root_find_files = "f", + -- open_lazy_root_live_grep = "g", + -- }, + -- -- Other telescope configuration options + -- }, + -- file_browser = {}, + -- }, +-- }) + + +local builtin = require('telescope.builtin') +local file_browser = require('telescope').extensions.file_browser.file_browser +vim.keymap.set('n', 'f', builtin.find_files, {}) +vim.keymap.set('n', 'g', builtin.live_grep, {}) +vim.keymap.set('n', 'b', builtin.buffers, {}) +vim.keymap.set('n', 'h', builtin.help_tags, {}) +vim.keymap.set('n', 'n', ":Telescope file_browser path=%:p:h select_buffer=true", {}) +--vim.keymap.set('n', 'n', file_browser, {}) +--vim.keymap.set('n', 'c', ":CtrlPTag", {}) +--vim.keymap.set('n', 'gd', ":tag ", {}) +--vim.keymap.set('n', 'gD', ":tselect ", {}) + +-- Setup language servers. +require('lspconfig').pyright.setup({ theme = "onedark" }) +--require('lspconfig').jedi_language_server.setup{} +--local lspconfig = require('lspconfig') + + +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +vim.keymap.set('n', 'e', vim.diagnostic.open_float) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist) + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + vim.keymap.set('i', '', vim.lsp.omnifunc, {}) + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + --vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + --vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'f', function() + vim.lsp.buf.format { async = true } + end, opts) + end, +}) + +require("lspconfig").gopls.setup({ theme = "onedark" }) + +local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {}) +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require('go.format').gofmt() + end, + group = format_sync_grp, +}) + +--local clangd_nvim = require('clangd_nvim') + +--require('nvim_lsp').clangd.setup{ + --capabilities = { + --textDocument = { + --semanticHighlightingCapabilities = { + --semanticHighlighting = true + --} + --} + --}, + --on_init = clangd_nvim.on_init +--} + +local set = vim.opt + +-- start of my own options +-- color schemes +vim.colorscheme = "onedark" +-- spellcheck +vim.cmd "setlocal spell spelllang=en_us" +vim.cmd "hi clear SpellBad" +vim.cmd "hi SpellBad cterm=underline" +-- show line on insert mode +vim.cmd "autocmd InsertEnter * set cursorline" +vim.cmd "autocmd InsertLeave * set nocursorline" +set.ttimeout = true +set.ttimeoutlen = 1 +set.ttyfast = true +-- basics +set.number = true +set.tabstop = 4 +set.shiftwidth = 4 +set.expandtab = true +-- instant search +set.incsearch = true +set.hlsearch = true +-- case insensitive searching +-- need both of the following for smartcase to work +set.ignorecase = true +set.smartcase = true +-- autoindent works weirdly sometimes +-- set.autoindent = true +vim.keymap.set("n", "gtl", ":tabn") +vim.keymap.set("n", "gth", ":tabp") +vim.keymap.set("n", "gt0", ":tabfirst") +vim.keymap.set("n", "gb", ":bprevious") +-- move tabs with gt +vim.keymap.set("n", "gtL", ":execute 'silent! tabmove ' . tabpagenr()") +vim.keymap.set("n", "gtH", ":execute 'silent! tabmove ' . (tabpagenr()-2)") +-- new tab +vim.keymap.set("n", "gtn", ":tabedit") +-- switch windows using g rather than +vim.keymap.set("n", "gwh", "h") +vim.keymap.set("n", "gwl", "l") +vim.keymap.set("n", "gwj", "j") +vim.keymap.set("n", "gwk", "k") +-- tags +vim.keymap.set("n", "c", ":tjump") +-- scroll before hitting edge of screen +set.scrolloff = 6 diff --git a/vim.py b/vim.py deleted file mode 100755 index e8f065f..0000000 --- a/vim.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python - -""" -This file will call `ctags` and then `vim` if called without arguments. -It will call `vim` immediately if called with arguments. - -Recommend renaming as just `vim` and placing in your path for convenience. - -Yes I know it would be very easy to implement this as a bash script, but -this python implementation works too, so whatever. -""" - -import os -import subprocess -import sys - -TAGS_FILE_PATH = os.path.abspath(os.path.join(".", "tags")) -CTAGS_PATH = "/usr/bin/ctags" -DOT_CTAGS_PATH = "$HOME/.ctags" -VIM_PATH = "/usr/bin/vim" - -# call vim directly if we're opening a specific file -if len(sys.argv) >= 2: - vim_args = [VIM_PATH] + sys.argv[1:] - os.execv(VIM_PATH, vim_args) - -# call ctags -try: - if os.path.exists(TAGS_FILE_PATH): - os.rename(TAGS_FILE_PATH, TAGS_FILE_PATH + ".bak") - ctags_cmd = [CTAGS_PATH] - proc = subprocess.Popen( - ctags_cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - stdout, stderr = proc.communicate() - if stderr: - print(stderr, file=sys.stderr) - sys.exit(1) -except PermissionError: - pass - -# call vim- if we get here `sys.argv[1:]` is an empty list -vim_args = [VIM_PATH] + sys.argv[1:] -os.execv(VIM_PATH, vim_args)