From c721b14f40720d5346a07934a0bacfbd94fd5a26 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Sun, 5 Jun 2022 09:15:29 +0300 Subject: [PATCH] added nvim with lua only, renamed older nvim without lua --- nvim/init.lua | 7 + nvim/lua/nvim/autopairs.lua | 25 +++ nvim/lua/nvim/cmp.lua | 136 +++++++++++++ nvim/lua/nvim/colorscheme.lua | 10 + nvim/lua/nvim/keymaps.lua | 66 +++++++ nvim/lua/nvim/lsp/handlers.lua | 104 ++++++++++ nvim/lua/nvim/lsp/init.lua | 8 + nvim/lua/nvim/lsp/lsp-installer.lua | 38 ++++ .../lsp/settings/jedi_language_server.lua | 1 + nvim/lua/nvim/lsp/settings/jsonls.lua | 183 ++++++++++++++++++ nvim/lua/nvim/lsp/settings/pyright.lua | 9 + nvim/lua/nvim/lsp/settings/sumneko_lua.lua | 15 ++ nvim/lua/nvim/options.lua | 40 ++++ nvim/lua/nvim/plugins.lua | 100 ++++++++++ .../coc-settings.json | 4 +- init.vim => nvim_0-4-4/init.vim | 1 + .../plug_settings}/autopairs/settings.vim | 0 .../plug_settings}/coc/mappings.vim | 0 .../plug_settings}/coc/settings.vim | 0 .../plug_settings}/floaterm/mappings.vim | 0 .../plug_settings}/nerdtree/mappings.vim | 0 .../plug_settings}/nerdtree/settings.vim | 0 nvim_0-4-4/plug_settings/scope/settings.vim | 13 ++ .../plug_settings}/startify/settings.vim | 0 .../plug_settings}/theme/airline.vim | 0 .../plug_settings}/theme/color.vim | 0 .../vim_settings}/mappings.vim | 10 +- .../vim_settings}/plugins.vim | 3 + .../vim_settings}/settings.vim | 3 +- plug_settings/scope/settings.vim | 5 - 30 files changed, 768 insertions(+), 13 deletions(-) create mode 100644 nvim/init.lua create mode 100644 nvim/lua/nvim/autopairs.lua create mode 100644 nvim/lua/nvim/cmp.lua create mode 100644 nvim/lua/nvim/colorscheme.lua create mode 100644 nvim/lua/nvim/keymaps.lua create mode 100644 nvim/lua/nvim/lsp/handlers.lua create mode 100644 nvim/lua/nvim/lsp/init.lua create mode 100644 nvim/lua/nvim/lsp/lsp-installer.lua create mode 100644 nvim/lua/nvim/lsp/settings/jedi_language_server.lua create mode 100644 nvim/lua/nvim/lsp/settings/jsonls.lua create mode 100644 nvim/lua/nvim/lsp/settings/pyright.lua create mode 100644 nvim/lua/nvim/lsp/settings/sumneko_lua.lua create mode 100644 nvim/lua/nvim/options.lua create mode 100644 nvim/lua/nvim/plugins.lua rename coc-settings.json => nvim_0-4-4/coc-settings.json (91%) rename init.vim => nvim_0-4-4/init.vim (99%) rename {plug_settings => nvim_0-4-4/plug_settings}/autopairs/settings.vim (100%) rename {plug_settings => nvim_0-4-4/plug_settings}/coc/mappings.vim (100%) rename {plug_settings => nvim_0-4-4/plug_settings}/coc/settings.vim (100%) rename {plug_settings => nvim_0-4-4/plug_settings}/floaterm/mappings.vim (100%) rename {plug_settings => nvim_0-4-4/plug_settings}/nerdtree/mappings.vim (100%) rename {plug_settings => nvim_0-4-4/plug_settings}/nerdtree/settings.vim (100%) create mode 100644 nvim_0-4-4/plug_settings/scope/settings.vim rename {plug_settings => nvim_0-4-4/plug_settings}/startify/settings.vim (100%) rename {plug_settings => nvim_0-4-4/plug_settings}/theme/airline.vim (100%) rename {plug_settings => nvim_0-4-4/plug_settings}/theme/color.vim (100%) rename {vim_settings => nvim_0-4-4/vim_settings}/mappings.vim (85%) rename {vim_settings => nvim_0-4-4/vim_settings}/plugins.vim (98%) rename {vim_settings => nvim_0-4-4/vim_settings}/settings.vim (94%) delete mode 100644 plug_settings/scope/settings.vim diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..c020c10 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,7 @@ +require("nvim.options") +require("nvim.keymaps") +require("nvim.plugins") +require("nvim.colorscheme") +require("nvim.cmp") +require("nvim.lsp") +require("nvim.autopairs") diff --git a/nvim/lua/nvim/autopairs.lua b/nvim/lua/nvim/autopairs.lua new file mode 100644 index 0000000..6e31b09 --- /dev/null +++ b/nvim/lua/nvim/autopairs.lua @@ -0,0 +1,25 @@ +-- If you want insert `(` after select function or method item +local status_ok, npairs = pcall(require, "nvim-autopairs") +if not status_ok then + return +end + +npairs.setup ({ + check_ts = true, + ts_config = { + lua = {"string"}, -- it will not add a pair on that treesitter node + javascript = {"template_string"}, + java = false, -- don't check treesitter on java + } +}) + +local cmp_autopairs = require('nvim-autopairs.completion.cmp') +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) + + +-- add a lisp filetype (wrap my-function), FYI: Hardcoded = { "clojure", "clojurescript", "fennel", "janet" } +cmp_autopairs.lisp[#cmp_autopairs.lisp+1] = "racket" diff --git a/nvim/lua/nvim/cmp.lua b/nvim/lua/nvim/cmp.lua new file mode 100644 index 0000000..711d6a7 --- /dev/null +++ b/nvim/lua/nvim/cmp.lua @@ -0,0 +1,136 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + print("Error loading cmp") + return +end + +local snip_status_ok, luasnip = pcall(require, "luasnip") +if not snip_status_ok then + print("Error loading snip") + return +end + +require("luasnip/loaders/from_vscode").lazy_load() + +local check_backspace = function() + local col = vim.fn.col "." - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" +end + +--   פּ ﯟ   some other good icons +local kind_icons = { + Text = "", + Method = "m", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", +} + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping { + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }, + [""] = cmp.mapping.confirm { select = false }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + }, + sources = { + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + experimental = { + ghost_text = true, + }, +} + +-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) diff --git a/nvim/lua/nvim/colorscheme.lua b/nvim/lua/nvim/colorscheme.lua new file mode 100644 index 0000000..7c7ca34 --- /dev/null +++ b/nvim/lua/nvim/colorscheme.lua @@ -0,0 +1,10 @@ +local status_ok, onedark = pcall(require, "onedark") +if not status_ok then + vim.notify("Error with colorscheme") + return +end + +onedark.setup { + style = "deep" +} +onedark.load() diff --git a/nvim/lua/nvim/keymaps.lua b/nvim/lua/nvim/keymaps.lua new file mode 100644 index 0000000..fdce539 --- /dev/null +++ b/nvim/lua/nvim/keymaps.lua @@ -0,0 +1,66 @@ +local opts = { noremap = true, silent = true } + +local function nnoremap(shortcut, command) + vim.keymap.set("n", shortcut, command, opts) +end +local function inoremap(shortcut, command) + vim.keymap.set("i", shortcut, command, opts) +end +local function vnoremap(shortcut, command) + vim.keymap.set("v", shortcut, command, opts) +end +local function xnoremap(shortcut, command) + vim.keymap.set("x", shortcut, command, opts) +end +local function tnoremap(shortcut, command) + vim.keymap.set("t", shortcut, command, opts) +end + +-- Define leader key +-- vim.api.nvim_set_keymap("", "", "", opts) +vim.g.mapleader = "\\" +vim.g.maplocalleader = "\\" + +-- Sane Y behaviour +nnoremap("Y", "y$") + +-- Better window navigation +nnoremap("", "h") +nnoremap("", "j") +nnoremap("", "k") +nnoremap("", "l") + +nnoremap("e", ":Lex 15") + +-- Resize +nnoremap("", ":vertical resize -2") +nnoremap("", ":resize +2") +nnoremap("", ":resize -2") +nnoremap("", ":vertical resize +2") + +-- Navigate Buffers +nnoremap("", ":bnext") +nnoremap("", ":bprevious") + +-- Quick ESC +inoremap("jk", "") + +-- Don't copy replaced text into register +-- while in visual mode, when pasting +vnoremap("p", "\"_dP") + +-- Move text up and down +vnoremap("", ":m .+1==") +vnoremap("", ":m .-2==") + +xnoremap("J", ":move '>+1gv-gv", opts) +xnoremap("K", ":move '<-2gv-gv", opts) +xnoremap("", ":move '>+1gv-gv", opts) +xnoremap("", ":move '<-2gv-gv", opts) + +-- Terminal -- +-- Better terminal navigation +tnoremap("", "h") +tnoremap("", "j") +tnoremap("", "k") +tnoremap("", "l") diff --git a/nvim/lua/nvim/lsp/handlers.lua b/nvim/lua/nvim/lsp/handlers.lua new file mode 100644 index 0000000..551a526 --- /dev/null +++ b/nvim/lua/nvim/lsp/handlers.lua @@ -0,0 +1,104 @@ +local M = {} + +-- TODO: backfill this to template +M.setup = function() + local signs = { + { name = "DiagnosticSignError", text = "" }, + { name = "DiagnosticSignWarn", text = "" }, + { name = "DiagnosticSignHint", text = "" }, + { name = "DiagnosticSignInfo", text = "" }, + } + + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end + + local config = { + -- disable virtual text + virtual_text = true, + -- show signs + signs = { + active = signs, + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +local function lsp_highlight_document(client) + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec( + [[ + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]], + false + ) + end +end + +local function lsp_keymaps(bufnr) + local opts = { noremap = true, silent = true } + 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", "rn", "lua vim.lsp.buf.rename()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", 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", "f", "lua vim.diagnostic.open_float()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", 'lua vim.diagnostic.goto_prev({ border = "rounded" })', opts) + vim.api.nvim_buf_set_keymap( + bufnr, + "n", + "gl", + 'lua vim.lsp.diagnostic.show_line_diagnostics({ border = "rounded" })', + opts + ) + vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", 'lua vim.diagnostic.goto_next({ border = "rounded" })', opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "q", "lua vim.diagnostic.setloclist()", opts) + vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] +end + +M.on_attach = function(client, bufnr) + if client.name == "tsserver" then + client.resolved_capabilities.document_formatting = false + end + lsp_keymaps(bufnr) + lsp_highlight_document(client) +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() + +local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not status_ok then + return +end + +M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities) + +return M diff --git a/nvim/lua/nvim/lsp/init.lua b/nvim/lua/nvim/lsp/init.lua new file mode 100644 index 0000000..e66a929 --- /dev/null +++ b/nvim/lua/nvim/lsp/init.lua @@ -0,0 +1,8 @@ +local status_ok, _ = pcall(require, "lspconfig") +if not status_ok then + print("Error with lspconfig") + return +end + +require("nvim.lsp.lsp-installer") +require("nvim.lsp.handlers").setup() diff --git a/nvim/lua/nvim/lsp/lsp-installer.lua b/nvim/lua/nvim/lsp/lsp-installer.lua new file mode 100644 index 0000000..2ceb9ac --- /dev/null +++ b/nvim/lua/nvim/lsp/lsp-installer.lua @@ -0,0 +1,38 @@ +local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") +if not status_ok then + print("Error with nvim-lsp-installer") + return +end + +-- Register a handler that will be called for all installed servers. +-- Alternatively, you may also register handlers on specific server instances instead (see example below). +lsp_installer.on_server_ready(function(server) + local opts = { + on_attach = require("nvim.lsp.handlers").on_attach, + capabilities = require("nvim.lsp.handlers").capabilities, + } + + if server.name == "jsonls" then + local jsonls_opts = require("nvim.lsp.settings.jsonls") + opts = vim.tbl_deep_extend("force", jsonls_opts, opts) + end + + if server.name == "sumneko_lua" then + local sumneko_opts = require("nvim.lsp.settings.sumneko_lua") + opts = vim.tbl_deep_extend("force", sumneko_opts, opts) + end + + if server.name == "pyright" then + local pyright_opts = require("nvim.lsp.settings.pyright") + opts = vim.tbl_deep_extend("force", pyright_opts, opts) + end + + if server.name == "jedi_language_server" then + local jedi_opts = require("nvim.lsp.settings.jedi_language_server") + opts = vim.tbl_deep_extend("force", jedi_opts, opts) + end + + -- This setup() function is exactly the same as lspconfig's setup function. + -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + server:setup(opts) +end) diff --git a/nvim/lua/nvim/lsp/settings/jedi_language_server.lua b/nvim/lua/nvim/lsp/settings/jedi_language_server.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/nvim/lua/nvim/lsp/settings/jedi_language_server.lua @@ -0,0 +1 @@ +return {} diff --git a/nvim/lua/nvim/lsp/settings/jsonls.lua b/nvim/lua/nvim/lsp/settings/jsonls.lua new file mode 100644 index 0000000..be362c9 --- /dev/null +++ b/nvim/lua/nvim/lsp/settings/jsonls.lua @@ -0,0 +1,183 @@ +-- Find more schemas here: https://www.schemastore.org/json/ +local schemas = { + { + description = "TypeScript compiler configuration file", + fileMatch = { + "tsconfig.json", + "tsconfig.*.json", + }, + url = "https://json.schemastore.org/tsconfig.json", + }, + { + description = "Lerna config", + fileMatch = { "lerna.json" }, + url = "https://json.schemastore.org/lerna.json", + }, + { + description = "Babel configuration", + fileMatch = { + ".babelrc.json", + ".babelrc", + "babel.config.json", + }, + url = "https://json.schemastore.org/babelrc.json", + }, + { + description = "ESLint config", + fileMatch = { + ".eslintrc.json", + ".eslintrc", + }, + url = "https://json.schemastore.org/eslintrc.json", + }, + { + description = "Bucklescript config", + fileMatch = { "bsconfig.json" }, + url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json", + }, + { + description = "Prettier config", + fileMatch = { + ".prettierrc", + ".prettierrc.json", + "prettier.config.json", + }, + url = "https://json.schemastore.org/prettierrc", + }, + { + description = "Vercel Now config", + fileMatch = { "now.json" }, + url = "https://json.schemastore.org/now", + }, + { + description = "Stylelint config", + fileMatch = { + ".stylelintrc", + ".stylelintrc.json", + "stylelint.config.json", + }, + url = "https://json.schemastore.org/stylelintrc", + }, + { + description = "A JSON schema for the ASP.NET LaunchSettings.json files", + fileMatch = { "launchsettings.json" }, + url = "https://json.schemastore.org/launchsettings.json", + }, + { + description = "Schema for CMake Presets", + fileMatch = { + "CMakePresets.json", + "CMakeUserPresets.json", + }, + url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json", + }, + { + description = "Configuration file as an alternative for configuring your repository in the settings page.", + fileMatch = { + ".codeclimate.json", + }, + url = "https://json.schemastore.org/codeclimate.json", + }, + { + description = "LLVM compilation database", + fileMatch = { + "compile_commands.json", + }, + url = "https://json.schemastore.org/compile-commands.json", + }, + { + description = "Config file for Command Task Runner", + fileMatch = { + "commands.json", + }, + url = "https://json.schemastore.org/commands.json", + }, + { + description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.", + fileMatch = { + "*.cf.json", + "cloudformation.json", + }, + url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json", + }, + { + description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.", + fileMatch = { + "serverless.template", + "*.sam.json", + "sam.json", + }, + url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json", + }, + { + description = "Json schema for properties json file for a GitHub Workflow template", + fileMatch = { + ".github/workflow-templates/**.properties.json", + }, + url = "https://json.schemastore.org/github-workflow-template-properties.json", + }, + { + description = "golangci-lint configuration file", + fileMatch = { + ".golangci.toml", + ".golangci.json", + }, + url = "https://json.schemastore.org/golangci-lint.json", + }, + { + description = "JSON schema for the JSON Feed format", + fileMatch = { + "feed.json", + }, + url = "https://json.schemastore.org/feed.json", + versions = { + ["1"] = "https://json.schemastore.org/feed-1.json", + ["1.1"] = "https://json.schemastore.org/feed.json", + }, + }, + { + description = "Packer template JSON configuration", + fileMatch = { + "packer.json", + }, + url = "https://json.schemastore.org/packer.json", + }, + { + description = "NPM configuration file", + fileMatch = { + "package.json", + }, + url = "https://json.schemastore.org/package.json", + }, + { + description = "JSON schema for Visual Studio component configuration files", + fileMatch = { + "*.vsconfig", + }, + url = "https://json.schemastore.org/vsconfig.json", + }, + { + description = "Resume json", + fileMatch = { "resume.json" }, + url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", + }, +} + +local opts = { + settings = { + json = { + schemas = schemas, + }, + }, + setup = { + commands = { + Format = { + function() + vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) + end, + }, + }, + }, +} + +return opts diff --git a/nvim/lua/nvim/lsp/settings/pyright.lua b/nvim/lua/nvim/lsp/settings/pyright.lua new file mode 100644 index 0000000..c43621d --- /dev/null +++ b/nvim/lua/nvim/lsp/settings/pyright.lua @@ -0,0 +1,9 @@ +return { + settings = { + python = { + analysis = { + typeCheckingMode = "strict", + } + } + }, +} diff --git a/nvim/lua/nvim/lsp/settings/sumneko_lua.lua b/nvim/lua/nvim/lsp/settings/sumneko_lua.lua new file mode 100644 index 0000000..9848bdd --- /dev/null +++ b/nvim/lua/nvim/lsp/settings/sumneko_lua.lua @@ -0,0 +1,15 @@ +return { + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, +} diff --git a/nvim/lua/nvim/options.lua b/nvim/lua/nvim/options.lua new file mode 100644 index 0000000..3345b79 --- /dev/null +++ b/nvim/lua/nvim/options.lua @@ -0,0 +1,40 @@ +local options = { + backup = false, + clipboard = "unnamedplus", + cmdheight = 1, + completeopt = { "menuone", "noselect" }, + conceallevel = 0, + fileencoding = "utf-8", + hlsearch = false, + showtabline = 4, + pumheight = 10, + smartcase = true, + smartindent = true, + smartindent = true, + splitbelow = true, + splitright = true, + swapfile = false, + termguicolors = true, + timeoutlen = 1000, + undofile = true, + updatetime = 300, + writebackup = false, + expandtab = true, + shiftwidth = 4, + tabstop = 4, + number = true, + relativenumber = true, + cursorline = true, + numberwidth = 4, + signcolumn = "yes", + wrap = false, + scrolloff = 8, + sidescrolloff = 8, + guifont = "monospace:h17", +} + +vim.opt.shortmess:append "c" + +for k, v in pairs(options) do + vim.opt[k] = v +end diff --git a/nvim/lua/nvim/plugins.lua b/nvim/lua/nvim/plugins.lua new file mode 100644 index 0000000..836e0ac --- /dev/null +++ b/nvim/lua/nvim/plugins.lua @@ -0,0 +1,100 @@ +local fn = vim.fn + +-- Automatically install packer +local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system { + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + } + print "Installing packer close and reopen Neovim ... " + vim.cmd [[packadd packer.nvim]] +end + +-- Autocommand that reloads neovim whenver you save the plugins.lua file +vim.cmd [[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerSync + augroup end +]] + +-- Use a protected call so we don't error out on the first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + vim.notify("Error with require packer") + return +end + +packer.init { + display = { + open_fn = function() + return require("packer.util").float {} + end, + }, +} + +-- Install plugins here +return packer.startup(function(use) + use "wbthomason/packer.nvim" -- Have packer manage itself + + + + -- PLUGINS BEGIN -- + -- An implementation of the Popup API from vim in Neovim + use "nvim-lua/popup.nvim" + + -- Useful lua functions used by lots of plugins + use "nvim-lua/plenary.nvim" + + -- Preview markdown files + use({ + "iamcco/markdown-preview.nvim", + run = function() vim.fn["mkdp#util#install"]() end, + }) + + -- Colorschemes + use "navarasu/onedark.nvim" + + -- cmp Plugins + use 'hrsh7th/nvim-cmp' + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/cmp-path' + use 'hrsh7th/cmp-cmdline' + use 'saadparwaiz1/cmp_luasnip' + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/cmp-nvim-lua' + + -- snippets + use 'L3MON4D3/LuaSnip' + use "rafamadriz/friendly-snippets" -- a bunch of snippets to use + + -- LSP + use "neovim/nvim-lspconfig" -- enable LSP + use "williamboman/nvim-lsp-installer" -- simple to use language server installer + + -- Commenter + use { + 'numToStr/Comment.nvim', + config = function() + require('Comment').setup() + end + } + + -- Autopairs + use "windwp/nvim-autopairs" + -- PLUGINS END -- + + + + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require("packer").sync() + end +end) diff --git a/coc-settings.json b/nvim_0-4-4/coc-settings.json similarity index 91% rename from coc-settings.json rename to nvim_0-4-4/coc-settings.json index 35a3216..9adbd42 100644 --- a/coc-settings.json +++ b/nvim_0-4-4/coc-settings.json @@ -29,7 +29,7 @@ } }, "diagnostic-languageserver.filetypes": { - "python": "flake8" + "python": "flake8-black" }, "diagnostic-languageserver.linters": { "flake8": { @@ -42,7 +42,7 @@ "setup.py" ], "args": [ - "--ignore=E402,C901,W503,W504,E116,E702,C0103,C0114,C0115,C0116,C0103,C0301,W0613,W0102,R0903,R0902,R0914,R0915,R0205,W0703,W0702,W0603", + "--ignore=E203,E402,C901,W503,W504,E116,E702,C0103,C0114,C0115,C0116,C0103,C0301,W0613,W0102,R0903,R0902,R0914,R0915,R0205,W0703,W0702,W0603", "--format=%(row)d,%(col)d,%(code).1s,%(code)s: %(text)s", "--max-line-length=88", "-" diff --git a/init.vim b/nvim_0-4-4/init.vim similarity index 99% rename from init.vim rename to nvim_0-4-4/init.vim index 56d6dd1..0036c5d 100644 --- a/init.vim +++ b/nvim_0-4-4/init.vim @@ -13,3 +13,4 @@ endfor for f in split(glob('$HOME/.config/nvim/plug_settings/*.vim'), '\n') exe 'source' f endfor + diff --git a/plug_settings/autopairs/settings.vim b/nvim_0-4-4/plug_settings/autopairs/settings.vim similarity index 100% rename from plug_settings/autopairs/settings.vim rename to nvim_0-4-4/plug_settings/autopairs/settings.vim diff --git a/plug_settings/coc/mappings.vim b/nvim_0-4-4/plug_settings/coc/mappings.vim similarity index 100% rename from plug_settings/coc/mappings.vim rename to nvim_0-4-4/plug_settings/coc/mappings.vim diff --git a/plug_settings/coc/settings.vim b/nvim_0-4-4/plug_settings/coc/settings.vim similarity index 100% rename from plug_settings/coc/settings.vim rename to nvim_0-4-4/plug_settings/coc/settings.vim diff --git a/plug_settings/floaterm/mappings.vim b/nvim_0-4-4/plug_settings/floaterm/mappings.vim similarity index 100% rename from plug_settings/floaterm/mappings.vim rename to nvim_0-4-4/plug_settings/floaterm/mappings.vim diff --git a/plug_settings/nerdtree/mappings.vim b/nvim_0-4-4/plug_settings/nerdtree/mappings.vim similarity index 100% rename from plug_settings/nerdtree/mappings.vim rename to nvim_0-4-4/plug_settings/nerdtree/mappings.vim diff --git a/plug_settings/nerdtree/settings.vim b/nvim_0-4-4/plug_settings/nerdtree/settings.vim similarity index 100% rename from plug_settings/nerdtree/settings.vim rename to nvim_0-4-4/plug_settings/nerdtree/settings.vim diff --git a/nvim_0-4-4/plug_settings/scope/settings.vim b/nvim_0-4-4/plug_settings/scope/settings.vim new file mode 100644 index 0000000..bf67c8d --- /dev/null +++ b/nvim_0-4-4/plug_settings/scope/settings.vim @@ -0,0 +1,13 @@ +augroup qs_colors + autocmd! + autocmd ColorScheme * highlight QuickScopePrimary + \ guifg='#00ff00' + \ gui=underline + \ ctermfg=155 + \ cterm=underline + autocmd ColorScheme * highlight QuickScopeSecondary + \ guifg='#0ffff' + \ gui=underline + \ ctermfg=81 + \ cterm=underline +augroup END diff --git a/plug_settings/startify/settings.vim b/nvim_0-4-4/plug_settings/startify/settings.vim similarity index 100% rename from plug_settings/startify/settings.vim rename to nvim_0-4-4/plug_settings/startify/settings.vim diff --git a/plug_settings/theme/airline.vim b/nvim_0-4-4/plug_settings/theme/airline.vim similarity index 100% rename from plug_settings/theme/airline.vim rename to nvim_0-4-4/plug_settings/theme/airline.vim diff --git a/plug_settings/theme/color.vim b/nvim_0-4-4/plug_settings/theme/color.vim similarity index 100% rename from plug_settings/theme/color.vim rename to nvim_0-4-4/plug_settings/theme/color.vim diff --git a/vim_settings/mappings.vim b/nvim_0-4-4/vim_settings/mappings.vim similarity index 85% rename from vim_settings/mappings.vim rename to nvim_0-4-4/vim_settings/mappings.vim index 3ed4d0a..259b3db 100644 --- a/vim_settings/mappings.vim +++ b/nvim_0-4-4/vim_settings/mappings.vim @@ -14,10 +14,10 @@ nnoremap k nnoremap l " Use alt +hjkl to resize windows -nnoremap :vertical resize -2 -nnoremap :resize -2 -nnoremap :resize +2 -nnoremap :vertical resize +2 +nnoremap :vertical resize -2 +nnoremap :resize -2 +nnoremap :resize +2 +nnoremap :vertical resize +2 " Remap escape inoremap jkl @@ -63,4 +63,4 @@ inoremap inoremap " Re-source vim -inoremap :source ~/.config/nvim/init.vim +nnoremap :source ~/.config/nvim/init.vim diff --git a/vim_settings/plugins.vim b/nvim_0-4-4/vim_settings/plugins.vim similarity index 98% rename from vim_settings/plugins.vim rename to nvim_0-4-4/vim_settings/plugins.vim index 10ae31f..94b8241 100644 --- a/vim_settings/plugins.vim +++ b/nvim_0-4-4/vim_settings/plugins.vim @@ -62,6 +62,9 @@ call plug#begin() " For Python f string highlighting Plug 'sheerun/vim-polyglot' + " Assembly + Plug 'Shirk/vim-gas' + call plug#end() " Coc List diff --git a/vim_settings/settings.vim b/nvim_0-4-4/vim_settings/settings.vim similarity index 94% rename from vim_settings/settings.vim rename to nvim_0-4-4/vim_settings/settings.vim index 4751330..237dfc0 100644 --- a/vim_settings/settings.vim +++ b/nvim_0-4-4/vim_settings/settings.vim @@ -21,6 +21,7 @@ augroup END set number relativenumber set hidden set nohlsearch +set guicursor=i:block au BufEnter * set fo-=c au BufEnter * set fo-=o @@ -31,7 +32,7 @@ set termguicolors set nobackup set nowritebackup -set updatetime=200 +set updatetime=500 set shortmess+=c augroup FileJinjaType diff --git a/plug_settings/scope/settings.vim b/plug_settings/scope/settings.vim deleted file mode 100644 index d80951e..0000000 --- a/plug_settings/scope/settings.vim +++ /dev/null @@ -1,5 +0,0 @@ -augroup qs_colors - autocmd! - autocmd ColorScheme * highlight QuickScopePrimary guifg='#ff00ff' gui=underline ctermfg=155 cterm=underline - autocmd ColorScheme * highlight QuickScopeSecondary guifg='#aa0000' gui=underline ctermfg=81 cterm=underline -augroup END -- 2.30.2