Perfect Neovim Ansible Setup (2024)

Lets start with information that I did not created that config. This Ansible oriented config was handed to me by one of my mates from the Linux world … and as it takes some steps needed to make it work specific only to FreeBSD – I thought that it may be a good reason to share them.

Perfect Neovim Ansible Setup (1)

I have split the article into the following parts is shown in Table of Contents below.

  • Neovim Config
  • Neovim Plugins
  • Needed Packages
  • Ansible Language Server
  • Some Modules Linuxisms
  • Alternatives
  • Summary

Lets start then.

Below are the Neovim config files located at ~/.config/nvim/lua/config place.

% wc -l ~/.config/nvim/lua/config/* 3 /home/vermaden/.config/nvim/lua/config/globals.lua 43 /home/vermaden/.config/nvim/lua/config/init.lua 24 /home/vermaden/.config/nvim/lua/config/keymaps.lua 53 /home/vermaden/.config/nvim/lua/config/options.lua 123 total% cat ~/.config/nvim/lua/config/globals.luavim.g.mapleader = " "vim.g.maplocalleader = " "% cat /home/vermaden/.config/nvim/lua/config/init.lualocal lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release lazypath, })endvim.opt.rtp:prepend(lazypath)require('config.globals')require('config.options')require('config.keymaps')local opts = { defaults = { lazy = true, }, install = { colorscheme = { "nightfox" } }, rtp = { disabled_plugins = { "gzip", "matchit", "matchparen", "netrw", "netrwPlugin", "tarPlugin", "tohtml", "tutor", "zipPlugin", } }, change_detection = { notify = true },}require("lazy").setup('plugins', opts)% cat ~/.config/nvim/lua/config/keymaps.lualocal keymap = vim.keymaplocal opts = { noremap = true, silent = true }-- DIRECTORY NAVIGATION ------------------------------------------------------keymap.set("n", "<leader>m", ":NvimTreeFocus<CR>", opts)keymap.set("n", "<leader>f", ":NvimTreeToggle<CR>", opts)keymap.set("n", "<C-k>", "<C-w>k", opts) -- NAVIGATE [^] UPkeymap.set("n", "<C-h>", "<C-w>h", opts) -- NAVIGATE [<] LEFTkeymap.set("n", "<C-l>", "<C-w>l", opts) -- NAVIGATE [>] RIGHTkeymap.set("n", "<C-j>", "<C-w>j", opts) -- NAVIGATE [v] DOWN-- WINDOW MANAGEMENT ---------------------------------------------------------keymap.set("n", "<leader>sv", ":vsplit<CR>", opts) -- SPLIT VERTICALLYkeymap.set("n", "<leader>sh", ":split<CR>", opts) -- SPLIT HORIZONTALLY-- INDENT --------------------------------------------------------------------keymap.set("v", "<", "<gv")keymap.set("v", ">", ">gv")-- COMMENTS ------------------------------------------------------------------vim.api.nvim_set_keymap("n", "<C-_>", "gcc", { noremap = false })vim.api.nvim_set_keymap("v", "<C-_>", "gcc", { noremap = false })% cat ~/.config/nvim/lua/config/options.lualocal opt = vim.opt-- TAB/INDENT ----------------------------------------------------------------opt.tabstop = 2opt.shiftwidth = 2opt.softtabstop = 2opt.expandtab = trueopt.smartindent = trueopt.wrap = false-- SEARCH --------------------------------------------------------------------opt.incsearch = trueopt.ignorecase = trueopt.smartcase = trueopt.hlsearch = false-- APPEARANCE ----------------------------------------------------------------opt.number = trueopt.relativenumber = falseopt.termguicolors = trueopt.colorcolumn = "100"opt.signcolumn = "yes"opt.cmdheight = 1opt.scrolloff = 10opt.completeopt = "menuone,noinsert,noselect"-- MISC ----------------------------------------------------------------------opt.hidden = trueopt.errorbells = falseopt.swapfile = falseopt.backup = falseopt.undodir = vim.fn.expand("~/.vim/undodir")opt.undofile = trueopt.backspace = "indent,eol,start"opt.splitright = trueopt.splitbelow = trueopt.autochdir = falseopt.modifiable = trueopt.encoding = "UTF-8"-- APPEND --------------------------------------------------------------------opt.mouse:append('a')opt.iskeyword:append("-")opt.clipboard:append("unnamedplus")-- ANSIBLE/YAML --------------------------------------------------------------vim.filetype.add({ extension = { yml = 'yaml.ansible' }})

That much for configs – now plugins.

The list of Neovim plugins in this config is shown below.

Perfect Neovim Ansible Setup (2)

… if some search engine would like to point here I will also list them in text.

  • comment.lua
  • indent-blankline.lua
  • init.lua
  • lualine-nvim.lua
  • mason-lspconfig.lua
  • mason.lua
  • nightfox.lua
  • noice.lua
  • nvim-cmp.lua
  • nvim-lspconfig.lua
  • nvim-tree.lua
  • nvim-treesitter.lua
  • nvim-ts-autotag.lua
  • nvim-web-devicons.lua
  • telescope.lua
  • vim-highlightedyank.lua
  • vim-illuminate.lua
  • whichkey.lua

Here are their contents.

% grep -A 1 return ~/.config/nvim/lua/plugins/* \ | grep -v -e -- -e return \ | awk '{print $NF}' \ | tr -d "\"',{}" \ | sort -uEdenEast/nightfox.nvimfolke/noice.nvimfolke/which-key.nvimhrsh7th/nvim-cmplukas-reineke/indent-blankline.nvimmachakann/vim-highlightedyankneovim/nvim-lspconfignumToStr/Comment.nvimnvim-lualine/lualine.nvimnvim-telescope/telescope.nvimnvim-tree/nvim-tree.luanvim-tree/nvim-web-deviconsnvim-treesitter/nvim-treesitterRRethy/vim-illuminatewilliamboman/mason-lspconfig.nvimwilliamboman/mason.nvimwindwp/nvim-ts-autotag

All these plugins are available – nvim-lua-plugins.tar.gz – here.

Execute below command to add them to Your Neovim dir.

% fetch -o - \ https://github.com/vermaden/scripts/raw/master/distfiles/nvim-lua-plugins.tar.gz \ | tar -C ~/.config/nvim/lua -xvf -- 3696 B 9804 kBps 00sx plugins/x plugins/noice.luax plugins/telescope.luax plugins/indent-blankline.luax plugins/whichkey.luax plugins/nvim-web-devicons.luax plugins/comment.luax plugins/nvim-tree.luax plugins/mason.luax plugins/nightfox.luax plugins/nvim-cmp.luax plugins/vim-highlightedyank.luax plugins/mason-lspconfig.luax plugins/init.luax plugins/nvim-treesitter.luax plugins/vim-illuminate.luax plugins/nvim-ts-autotag.luax plugins/lualine-nvim.luax plugins/nvim-lspconfig.lua

Just in case if WordPress would mess any part of Neovim config – You may find all of the configuration and plugins in one file – ~/.config/nvim – available here.

Besides the obvious Neovim packages there are some additional ones needed to make entire setup work.

# pkg install -y \ neovim \ npm \ node \ gcc13 \ gmake

That is it. That is probably the most simple part of this article.

After I dumped that Neovim config into the ~/.config/nvim dir I learned that it is a lot more advanced then I thought – to the point that it needs an external dedicated ansible-language-server needed for the Ansible playbook completions.

Perfect Neovim Ansible Setup (3)

I used the most recent 1.2.1 release of ansible-language-server … and used the ALS Documentation for the instructions to build it properly.

% fetch https://github.com/ansible/ansible-language-server/archive/refs/tags/v1.2.1.tar.gz% tar -xzvf v1.2.1.tar.gz% cd ansible-language-server-1.2.1% npm install .

Lets check if the ansible-language-server built properly … and that it actually works.

% find . -name server.js -o -name ansible-language-server./bin/ansible-language-server./out/server/src/server.js./node_modules/vscode-languageserver/lib/common/server.js% node ./out/server/src/server.js --stdio  ^C

Seems to work as desired.

As I already use ~/scripts/bin place as additional ingredient to my PATH environment I will put it there … kinda.

% echo ${PATH} | tr ':' '\n' | grep scripts/home/vermaden/scripts/home/vermaden/scripts/bin% pwd/home/vermaden/ansible-language-server-1.2.1% cd ..% mv ansible-language-server-1.2.1 ~/scripts/% ln -s \ ~/scripts/ansible-language-server-1.2.1/bin/ansible-language-server \ ~/scripts/bin/ansible-language-server% rehash || hash -r

When we now start Neovim it does not cry that ansible-language-server is not available – so that part seems to work properly.

When You first start that Neovim setup it will start to fetch/build/configure all these plugins.

Perfect Neovim Ansible Setup (4)

For the record – if something fails its safe to remove the ~/.local/share/nvim dir and start over.

% rm -rf ~/.local/share/nvim% nvim

… and it fails to build LuaSnip module.

Perfect Neovim Ansible Setup (5)

Maybe it will do better with GNU make(1) instead of BSD make(1) – lets try that.

~ # cd /usr/bin/usr/bin # mv make make.FreeBSD/usr/bin # ln -s /usr/local/bin/gmake make

Lets try now with GNU make(1) instead.

Perfect Neovim Ansible Setup (6)

Now the gcc seems to be missing … but we installed lang/gcc13 packages at the beginning …

% pkg info -l gcc13 | grep bin/gcc /usr/local/bin/gcc-ar13 /usr/local/bin/gcc-nm13 /usr/local/bin/gcc-ranlib13 /usr/local/bin/gcc13

Right … its gcc13 and not gcc

Lets create the gcc link that points to gcc13 then.

# ln -s /usr/local/bin/gcc13 /usr/local/bin/gcc# /bin/ls -l /usr/local/bin/gcclrwxr-xr-x 1 root wheel 20 Mar 11 07:27 /usr/local/bin/gcc -> /usr/local/bin/gcc13

Lets try again …

Perfect Neovim Ansible Setup (7)

Seems that it worked. All modules fetched/built/configured successfully as shown below.

Perfect Neovim Ansible Setup (8)

Lets now check how it runs with some Ansible YAML file.

Perfect Neovim Ansible Setup (9)

Seems that its processing it …

Perfect Neovim Ansible Setup (10)

Yeah … a lot of hints for a start … sounds kinda like Clippy from some oldschool Office suite.

Perfect Neovim Ansible Setup (11)

… always helpful with a bunch of hints 🙂

The same Ansible playbook after applying the suggestions.

Perfect Neovim Ansible Setup (12)

Seems like fixed.

Now … lets revoke the GNU make(1) change.

~ # cd /usr/bin/usr/bin # rm make/usr/bin # mv make.FreeBSD make

I tried to submit this behavior as issue on LuaSnip page – https://github.com/L3MON4D3/LuaSnip/issues/1140 – but no reaction till now.

Before I got this config I tried to setup plain vim(1) as Ansible oriented setup … and to be honest it also works quite well for me. It’s also calmer as the Clippy is not available here and does not share its thoughts all the time.

Perfect Neovim Ansible Setup (13)

Seems pretty decent. The completion also works – but its limited and based on file contents. One may overcome that with opening TWO files at once each time to edit an Ansible playbook. The first file would be the one You want to edit – the second one would be prepared Ansible playbook that contains all modules and all options for these modules … of course the completion would not be per module aware but still – somewhat helpful. Below is simple vim(1) completion spawned by [CTRL]+[N] (also known as ^n in UNIX notation) shortcut in INSERT mode.

Perfect Neovim Ansible Setup (14)

… and Neovim completion for comparison with the same shortcut used.

Perfect Neovim Ansible Setup (15)

It is very simple and basic vim(1) config w/o any additional modules or plugins – just plain ~/vimrc file.

% cat ~/.vimrc" -- GENERAL --------------------------------------------------------------- "  syntax on set nomodeline set nocompatible set backspace=indent,eol,start set autoindent set nobackup set cursorline set number set nowrap set history=32 set ignorecase set showcmd set incsearch set hlsearch set tabstop=2 set shiftwidth=2 set softtabstop=2 set shiftwidth=2 set expandtab set ruler set mouse-=a highlight ColorColumn ctermbg=0 guibg=blue let &colorcolumn="100,".join(range(100,999),",") let g:indentLine_char = '¦' " -- DISABLE ~/.viminfo FILE ----------------------------------------------- " let skip_defaults_vim=1 set viminfo=""" -- COMMANDS -------------------------------------------------------------- " command WQ wq command Wq wq command W w command Q q

I am also a big fan of Geany IDE/editor (depending on how you configure it) and its also a good companion in the Ansible world.

Perfect Neovim Ansible Setup (16)

Hope that this Neovim config would help You in your daily Ansible work … and let me know it now and why 🙂

Regards.

UPDATE 1 – Lua and General Purpose Language Servers

After I opened some Lua config in this nvim(1) config it welcomed me with this message below.

Perfect Neovim Ansible Setup (17)

So I started to dig this topic … and as as result added both lua-language-server and efm-langserver servers to this config.

Lua Language Server

While initial research did not encouraged – https://github.com/LuaLS/lua-language-server/issues/2361 – I manged to omit the tests that are broken on FreeBSD … and the lua-language-server seems to just work.

Below are build/install instructions.

# pkg install ninja% git clone https://github.com/LuaLS/lua-language-server.git% cd lua-language-server% :> 3rd/bee.lua/test/test.lua% :> test.lua% ./make.sh% ./bin/lua-language-serverContent-Length: 120{"jsonrpc":"2.0","method":"$/status/report","params":{"text":"Lua","tooltip":"Cached files: 0/0\nMemory usage: 2M"}}

Seems to work – will now copy to my preferred ${PATH} place – feel free to choose your own different place.

% cp bin/lua-language-server ~/scripts/bin% rm -rf ~/lua-language-server

General Purpose Language Server

… and now the efm-langserver part.

# pkg install go gmake% git clone https://github.com/mattn/efm-langserver.git% cd efm-langserver% gmake% ./efm-langserver2024/03/14 07:54:26 efm-langserver: no configuration file2024/03/14 07:54:26 efm-langserver: reading on stdin, writing on stdout

Seems to work – now the install part as previously.

% cp efm-langserver ~/scripts/bin% rm -rf ~/efm-langserver

… and now Neovim starts and behaves properly.

Perfect Neovim Ansible Setup (18)

Regards.

UPDATE 2 – Bash Language Server

I though that as Bash Language Server also exists – why also not add it to the setup?

Initially I was skeptic as there were no build instructions on the GitHub page … but that resolved even better then I though.

The only thing needed was the npm i -g bash-language-server command listed there … and it worked like a charm.

The above command of course will work after You have done all the other stuff in this guide above.

Here is how it looked in the xterm(1) terminal.

Perfect Neovim Ansible Setup (19)

… and the commands to copy (for less typing).

w520 % doas npm i -g bash-language-serveradded 33 packages in 3s4 packages are looking for funding run `npm fund` for detailsw520 % npm fundbash-language-serverw520 % npm list -g --depth=0  /usr/local/lib├── bash-language-server@5.1.2├── corepack@0.22.0├── npm@10.5.1└── yarn@1.22.19w520 % rehash  w520 % which bash-language-server /usr/local/bin/bash-language-serverw520 % /usr/local/bin/bash-language-serverUsage: bash-language-server start Start listening on stdin/stdout bash-language-server -h, --help Display this help and exit bash-language-server -v, --version Print the version and exitEnvironment variables: BASH_IDE_LOG_LEVEL Set the log level (default: info)Further documentation: https://github.com/bash-lsp/bash-language-server

Regards.

UPDATE 3 – Ansible Language Server from npm(1) Packages

While having fun with Bash Language Server from previous UPDATE 2 I also found a way for easier and faster installation of the Ansible Language Server – by using npm(1) packages. I did not updated the entire article for it – as there is an older 1.1.0 version of it available – and the article focuses on the latest and supported one – but still – if You just need fast and easy a working Ansible Language Server and it does not have to be in the latest version – it will work more then well.

You will still need to install required packages by using pkg(8) manager.

w520 root ~ # pkg install -y \ neovim \ npm \ node \ gcc13 \ gmake

Then You can ‘just’ install the Ansible Language Server with npm(1) command.

w520 root ~ # npm i -g ansible-language-server npm WARN deprecated ansible-language-server@0.1.1-0: Package no longer supported.Contact Support at https://www.npmjs.com/support for more info.added 34 packages in 3s4 packages are looking for funding run `npm fund` for details

And a few moments later its installed.

w520 vermaden ~ % npm list -g --depth=0  /usr/local/lib├── ansible-language-server@0.1.1-0├── bash-language-server@5.1.2├── corepack@0.22.0├── npm@10.5.1└── yarn@1.22.19

This is how it looked on my machine.

Perfect Neovim Ansible Setup (20)

Regards.

EOF

Perfect Neovim Ansible Setup (2024)
Top Articles
2024 Hiring and Compensation Trends: Numbers to Know in a Complex Labor Market
Robert Half on LinkedIn: 2023 Salary Guide | Robert Half | 24 comments
Cooking Chutney | Ask Nigella.com
Best Team In 2K23 Myteam
Uihc Family Medicine
Us 25 Yard Sale Map
Farmers Branch Isd Calendar
The Powers Below Drop Rate
My Vidant Chart
ᐅ Bosch Aero Twin A 863 S Scheibenwischer
Log in or sign up to view
Average Salary in Philippines in 2024 - Timeular
Mikayla Campinos Laek: The Rising Star Of Social Media
Swgoh Blind Characters
Rural King Credit Card Minimum Credit Score
MLB power rankings: Red-hot Chicago Cubs power into September, NL wild-card race
Ice Dodo Unblocked 76
Www.dunkinbaskinrunsonyou.con
European city that's best to visit from the UK by train has amazing beer
Www.craigslist.com Austin Tx
Does Hunter Schafer Have A Dick
Naya Padkar Gujarati News Paper
What Individuals Need to Know When Raising Money for a Charitable Cause
The Banshees Of Inisherin Showtimes Near Broadway Metro
Water Temperature Robert Moses
Keyn Car Shows
Current Time In Maryland
Siskiyou Co Craigslist
Soiza Grass
Craigslist Gigs Norfolk
Flixtor Nu Not Working
B.k. Miller Chitterlings
CVS Near Me | Somersworth, NH
Laurin Funeral Home | Buried In Work
Avance Primary Care Morrisville
Hometown Pizza Sheridan Menu
Verizon Outage Cuyahoga Falls Ohio
Lacy Soto Mechanic
Immobiliare di Felice| Appartamento | Appartamento in vendita Porto San
Mbfs Com Login
Lyndie Irons And Pat Tenore
Dragon Ball Super Super Hero 123Movies
Rush Copley Swim Lessons
Why Are The French So Google Feud Answers
Gw2 Support Specter
Server Jobs Near
Cara Corcione Obituary
1990 cold case: Who killed Cheryl Henry and Andy Atkinson on Lovers Lane in west Houston?
Helpers Needed At Once Bug Fables
Strange World Showtimes Near Century Federal Way
Bloons Tower Defense 1 Unblocked
Equinox Great Neck Class Schedule
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 5739

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.