From b3216433c492aecac8fc125974ceb7d5e75f6753 Mon Sep 17 00:00:00 2001 From: Dietrich Rink Date: Sat, 10 Jun 2023 15:25:00 +0200 Subject: [PATCH] add python variant --- python/Containerfile | 16 ++++++++++++++++ python/nvim/init/python.lua | 13 +++++++++++++ python/nvim/snippets/python.snippets | 5 +++++ 3 files changed, 34 insertions(+) create mode 100644 python/Containerfile create mode 100644 python/nvim/init/python.lua create mode 100644 python/nvim/snippets/python.snippets diff --git a/python/Containerfile b/python/Containerfile new file mode 100644 index 0000000..1bac140 --- /dev/null +++ b/python/Containerfile @@ -0,0 +1,16 @@ +FROM code-basic +USER root +ENV HOME=/root + +# Install alpine packages +RUN apk add --no-cache python3 python3-doc py3-pip py3-pip-doc + +# Install pip packages +RUN pip install --no-cache-dir python-lsp-server + +# Add neovim config +COPY nvim /etc/xdg/nvim + +# Configure environment +USER 1000:1000 +ENV HOME=/tmp diff --git a/python/nvim/init/python.lua b/python/nvim/init/python.lua new file mode 100644 index 0000000..19fa144 --- /dev/null +++ b/python/nvim/init/python.lua @@ -0,0 +1,13 @@ +local lspconfig = require('lspconfig') + +-- Get python executable from env +local python = vim.fn.globpath(vim.fn.getcwd(), "env/bin/python") + +-- Set configuration +local config = {} +if python ~= '' then + config.cmd = { python, '-m', 'pylsp' } +end + +-- Set up pylsp +lspconfig.pylsp.setup(config) diff --git a/python/nvim/snippets/python.snippets b/python/nvim/snippets/python.snippets new file mode 100644 index 0000000..14d5552 --- /dev/null +++ b/python/nvim/snippets/python.snippets @@ -0,0 +1,5 @@ +snippet #! + #!/usr/bin/env python3 +snippet def + def ${1:name}(${2}): + ${0}