From a7d2efc750bad0f958abb146979a12691b548e50 Mon Sep 17 00:00:00 2001 From: Alyxia Sother Date: Sun, 12 Dec 2021 12:19:48 +0100 Subject: [PATCH 1/3] [nvim] Add some Lua utils --- nvim/lua/kdotfiles/utils.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 nvim/lua/kdotfiles/utils.lua diff --git a/nvim/lua/kdotfiles/utils.lua b/nvim/lua/kdotfiles/utils.lua new file mode 100644 index 0000000..17e4ef7 --- /dev/null +++ b/nvim/lua/kdotfiles/utils.lua @@ -0,0 +1,28 @@ +local M = require('dotfiles.autoload')('kdotfiles.utils') + +function M.file_exists(file) + local f = io.open(file, "rb") + if f then f:close() end + return f ~= nil +end + +function M.lines_from(file) + if not M.file_exists(file) then return {} end + lines = {} + for line in io.lines(file) do + lines[#lines + 1] = line + end + return lines +end + +function M.get_os(lines) + os_name = "Unknown" + for k,v in pairs(lines) do + if string.match(v, "^ID=") then + os_name = string.sub(v, 4) + end + end + return os_name +end + +return M From 444dc81d1b49e6b4cd536ddd224c9e2b395040c4 Mon Sep 17 00:00:00 2001 From: Alyxia Sother Date: Sun, 12 Dec 2021 12:19:53 +0100 Subject: [PATCH 2/3] [nvim] Add HTML lspconfig --- nvim/dotfiles/lspconfigs/html.lua | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 nvim/dotfiles/lspconfigs/html.lua diff --git a/nvim/dotfiles/lspconfigs/html.lua b/nvim/dotfiles/lspconfigs/html.lua new file mode 100644 index 0000000..6b9fec4 --- /dev/null +++ b/nvim/dotfiles/lspconfigs/html.lua @@ -0,0 +1,34 @@ +local utils = require('kdotfiles.utils') +local lspconfig = require('lspconfig') + +local file = '/etc/os-release' +local lines = utils.lines_from(file) +local os_name = utils.get_os(lines) + +local cmd = (os_name == 'arch') and {'vscode-html-languageserver'} or {'vscode-html-language-server'} +vim.list_extend(cmd, {'--stdio'}) + +lspconfig['html'].setup({ + cmd = cmd; + filetypes = {'html', 'handlebars', 'htmldjango', 'blade'}; + completion_menu_label = 'HTML'; + + settings_scopes = {'html', 'css', 'javascript'}; + settings = { + html = { + format = { + enable = false; + }; + }; + javascript = { + format = { + enable = false; + }; + }; + css = { + format = { + enable = false; + }; + }; + }; +}) From cd8449079001a9a01765664cdb014f5385c3c6f6 Mon Sep 17 00:00:00 2001 From: Alyxia Sother Date: Sun, 12 Dec 2021 21:04:24 +0100 Subject: [PATCH 3/3] [nvim] Add PHP lspconfig --- nvim/dotfiles/lspconfigs/php.lua | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 nvim/dotfiles/lspconfigs/php.lua diff --git a/nvim/dotfiles/lspconfigs/php.lua b/nvim/dotfiles/lspconfigs/php.lua new file mode 100644 index 0000000..fd01699 --- /dev/null +++ b/nvim/dotfiles/lspconfigs/php.lua @@ -0,0 +1,3 @@ +local lspconfig = require('lspconfig') + +lspconfig['phpactor'].setup({})