From d47ae6c9a7f28002fb8a9889fe821f134adf6fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20Fussing=20M=C3=B8rk?= Date: Thu, 25 Aug 2022 14:11:17 +0200 Subject: [PATCH] Updated Neovim config to lua --- neovim/.config/nvim/init.lua | 12 +++++++ neovim/.config/nvim/lua/completion.lua | 26 +++++++++++++++ neovim/.config/nvim/lua/keybindings.lua | 12 +++++++ neovim/.config/nvim/lua/plugins.lua | 39 ++++++++++++++++++++++ neovim/.config/nvim/lua/python.lua | 6 ++++ neovim/.config/nvim/lua/test.py | 8 +++++ neovim/.config/nvim/lua/visuals.lua | 43 +++++++++++++++++++++++++ 7 files changed, 146 insertions(+) create mode 100644 neovim/.config/nvim/init.lua create mode 100644 neovim/.config/nvim/lua/completion.lua create mode 100644 neovim/.config/nvim/lua/keybindings.lua create mode 100644 neovim/.config/nvim/lua/plugins.lua create mode 100644 neovim/.config/nvim/lua/python.lua create mode 100644 neovim/.config/nvim/lua/test.py create mode 100644 neovim/.config/nvim/lua/visuals.lua diff --git a/neovim/.config/nvim/init.lua b/neovim/.config/nvim/init.lua new file mode 100644 index 0000000..76beec5 --- /dev/null +++ b/neovim/.config/nvim/init.lua @@ -0,0 +1,12 @@ +require('plugins') +require('visuals') +require('completion') +require('python') +require('keybindings') + +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.clipboard = 'unnamedplus' +vim.opt.smartindent = true diff --git a/neovim/.config/nvim/lua/completion.lua b/neovim/.config/nvim/lua/completion.lua new file mode 100644 index 0000000..e05a05c --- /dev/null +++ b/neovim/.config/nvim/lua/completion.lua @@ -0,0 +1,26 @@ +local cmp = require("cmp") +cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'copilot', group_index = 2 }, + { name = 'nvim_lsp', group_index = 2 }, + }, { + { name = 'buffer' }, + }) +}) diff --git a/neovim/.config/nvim/lua/keybindings.lua b/neovim/.config/nvim/lua/keybindings.lua new file mode 100644 index 0000000..87d0d17 --- /dev/null +++ b/neovim/.config/nvim/lua/keybindings.lua @@ -0,0 +1,12 @@ +vim.api.nvim_set_keymap('n', '', + "lua require('fzf-lua').files()", + { noremap = true, silent = true } +) +vim.api.nvim_set_keymap('n', '', + "lua require('fzf-lua').buffers()", + { noremap = true, silent = true } +) + +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) +vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) +vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) diff --git a/neovim/.config/nvim/lua/plugins.lua b/neovim/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..35b7023 --- /dev/null +++ b/neovim/.config/nvim/lua/plugins.lua @@ -0,0 +1,39 @@ +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + -- Visuals + use 'shaunsingh/nord.nvim' + use 'kyazdani42/nvim-web-devicons' + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true } + } + + -- File Handling + use { 'ibhagwan/fzf-lua', + requires = { 'kyazdani42/nvim-web-devicons' } + } + + -- Completion + use 'github/copilot.vim' + use 'hrsh7th/nvim-cmp' + use 'L3MON4D3/LuaSnip' + use { + "zbirenbaum/copilot.lua", + event = {"VimEnter"}, + config = function() + vim.defer_fn(function() + require("copilot").setup() + end, 100) + end, + } + use { + "zbirenbaum/copilot-cmp", + module = "copilot_cmp", + } + use 'hrsh7th/cmp-nvim-lsp' + + -- Python + use 'neovim/nvim-lspconfig' +end) diff --git a/neovim/.config/nvim/lua/python.lua b/neovim/.config/nvim/lua/python.lua new file mode 100644 index 0000000..de00ec6 --- /dev/null +++ b/neovim/.config/nvim/lua/python.lua @@ -0,0 +1,6 @@ +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + +require'lspconfig'.pyright.setup{ + capabilities = capabilities, +} diff --git a/neovim/.config/nvim/lua/test.py b/neovim/.config/nvim/lua/test.py new file mode 100644 index 0000000..5abf4a8 --- /dev/null +++ b/neovim/.config/nvim/lua/test.py @@ -0,0 +1,8 @@ +def __main__(): + print("Hello World") + return 0 + +if __name__ == "__main__": + __main__() + print("Hello World") + return 0 # This is a comment diff --git a/neovim/.config/nvim/lua/visuals.lua b/neovim/.config/nvim/lua/visuals.lua new file mode 100644 index 0000000..1580a49 --- /dev/null +++ b/neovim/.config/nvim/lua/visuals.lua @@ -0,0 +1,43 @@ +vim.opt.termguicolors = true +vim.cmd[[colorscheme nord]] + +require('lualine').setup { + options = { + icons_enabled = false, + theme = 'nord', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +}