From 93caf0c971f66661cbc3509cacd6c5b9936ed34d Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 31 Jan 2022 22:41:13 +0200 Subject: [PATCH] feat: tried adding the nvim lspconifg --- dotfiles/neovim/init.lua | 1 + dotfiles/neovim/lua/my/keymaps.lua | 4 +- dotfiles/neovim/lua/my/plugins/init.lua | 10 ++++ dotfiles/neovim/lua/my/plugins/lspconfig.lua | 50 ++++++++++++++++++++ modules/applications/misc.nix | 1 + modules/applications/neovim.nix | 12 ++++- modules/overlays/edopro/edopro.nix | 7 ++- 7 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 dotfiles/neovim/lua/my/plugins/init.lua create mode 100644 dotfiles/neovim/lua/my/plugins/lspconfig.lua diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index e4b0a2c..376a407 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -33,3 +33,4 @@ require('github-theme').setup({ -- Import my other files require('my.keymaps').setup() +require('my.plugins').setup() diff --git a/dotfiles/neovim/lua/my/keymaps.lua b/dotfiles/neovim/lua/my/keymaps.lua index 3b01ae2..369163b 100644 --- a/dotfiles/neovim/lua/my/keymaps.lua +++ b/dotfiles/neovim/lua/my/keymaps.lua @@ -1,13 +1,13 @@ local M = {} -local function map(mode, lhs, rhs, opts) +function M.map(mode, lhs, rhs, opts) local options = {noremap = true} if opts then options = vim.tbl_extend('force', options, opts) end vim.api.nvim_set_keymap(mode, lhs, rhs, options) end function M.setup() - map("i", "jj", "") -- Remap Esc to + M.map("i", "jj", "") -- Remap Esc to end return M \ No newline at end of file diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua new file mode 100644 index 0000000..afe5da6 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/init.lua @@ -0,0 +1,10 @@ +local M = {} + +function M.setup() + require("my.plugins.lspconfig").setup() + + -- Other unconfigured plugins + require('nvim-autopairs').setup() +end + +return M \ No newline at end of file diff --git a/dotfiles/neovim/lua/my/plugins/lspconfig.lua b/dotfiles/neovim/lua/my/plugins/lspconfig.lua new file mode 100644 index 0000000..6bb1e76 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/lspconfig.lua @@ -0,0 +1,50 @@ +local M = {} + +-- Use a loop to conveniently call 'setup' on multiple servers and +-- map buffer local keybindings when the language server attaches +local servers = { "tsserver" "purescriptls" } + +function M.map(buf, mode, lhs, rhs, opts) + local options = { noremap=true, silent=true } + if opts then options = vim.tbl_extend('force', options, opts) end + map(buf, mode, lhs, rhs, options) +end + +function on_attach(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Go to declaration / definition / implementation + map(bufnr, "n", 'gD', 'lua vim.lsp.buf.declaration()') + map(bufnr, "n", 'gd', 'lua vim.lsp.buf.definition()') + map(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()') + + -- Hover + map(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()') + map(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()') + + -- Workspace stuff + map(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()') + map(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()') + map(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))') + + -- Code actions + map(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()') + map(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()') + map(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()') + map(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()') + map(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()') +end + +function M.setup() + for _, lsp in pairs(servers) do + require('lspconfig')[lsp].setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, -- This will be the default in neovim 0.7+ + } + } + end +end + +return M \ No newline at end of file diff --git a/modules/applications/misc.nix b/modules/applications/misc.nix index 8d78797..6be1a8e 100644 --- a/modules/applications/misc.nix +++ b/modules/applications/misc.nix @@ -72,5 +72,6 @@ # games # tetrio-desktop # mindustry + edopro ]; } diff --git a/modules/applications/neovim.nix b/modules/applications/neovim.nix index 9f4de73..0c07242 100644 --- a/modules/applications/neovim.nix +++ b/modules/applications/neovim.nix @@ -14,7 +14,17 @@ in { luafile ${config-nvim}/init.lua ''; - plugins = with pkgs.vimExtraPlugins; [ config-nvim github-nvim-theme ]; + extraPackages = [ + pkgs.nodePackages.typescript + pkgs.easy-purescript-nix.purescript-language-server + ]; + plugins = with pkgs.vimPlugins; + with pkgs.vimExtraPlugins; [ + config-nvim # my neovim config + github-nvim-theme # github theme for neovim + nvim-lspconfig # configures lsps for me + nvim-autopairs # close pairs for me + ]; }; } diff --git a/modules/overlays/edopro/edopro.nix b/modules/overlays/edopro/edopro.nix index 9a2cdd7..4e54a27 100644 --- a/modules/overlays/edopro/edopro.nix +++ b/modules/overlays/edopro/edopro.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs ? import , ... }: pkgs.stdenv.mkDerivation rec { pname = "edopro"; version = "39.2.0"; @@ -7,6 +7,7 @@ pkgs.stdenv.mkDerivation rec { src = pkgs.fetchurl { url = "https://github.com/ProjectIgnis/edopro-assets/releases/download/${rev}/ProjectIgnis-EDOPro-${version}-linux.tar.gz"; + sha256 = "OQSWTuRaTyr2XIDjSbIvrV11LJCpOmw5aOjHU2ji+kI="; }; buildInputs = [ pkgs.mono ]; @@ -15,6 +16,8 @@ pkgs.stdenv.mkDerivation rec { installPhase = '' mkdir -p $out/bin - mv edopro $out/bin + ls + chmod +x ./EDOPro + mv ./* $out/bin/ ''; }