1
submitted 1 year ago by Nico792@lemmy.ml to c/neovim@sopuli.xyz

Hi, I’m new to neovim so there’s a decent chance this is just a rookie mistake. I wanted to make an autocmd to remap F5 to running the (python) file. I found a stack overflow post on how to do this (https://stackoverflow.com/questions/18948491/running-python-code-in-vim ) but that was for vim. I tried my best to translate if for neovim using some other tutorials I found (and doing my best at understanding docs), what I came up with is this:

local api = vim.api
local RunFile = api.nvim_create_augroup("RunFile", { clear = true })

api.nvim_create_autocmd(
    "FileType",
    {
        callback = "map <buffer> <F5> :w<cr>:exec '!python3' shellescape(@%, 1)<cr>",
        pattern = "python",
        group = RunFile,
    }
)

however when I include the file in my init.lua, not only does it not work (the autocmd doesn’t even show up when looking in :au FileType, let alone run) it also makes the text a boring white and when I try to format, it gives the error [LSP] Format request failed, no matching language servers. while I definitely do have the language server (it works when the autocmd file is not included in init.lua). I’m probably just making some simple mistakes, but I cannot for the life of me find what I’m doing wrong. Does anyone here have any suggestions? For the record, I use lsp zero and treesitter

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here
this post was submitted on 26 Jun 2023
1 points (100.0% liked)

Neovim

3 readers
1 users here now

Neovim is a modal text editor forked off of Vim in 2014. Being modal means that you do not simply type text on screen, but the behavior and functionality of the editor changes entirely depending on the mode.

The most common and most used mode, the "normal mode" for Neovim is to essentially turn your keyboard in to hotkeys with which you can navigate and manipulate text. Several modes exist, but two other most common ones are "insert mode" where you type in text directly as if it was a traditional text editor, and "visual mode" where you select text.

Neovim seeks to enable further community participation in its development and to make drastic changes without turning it in to something that is "not Vim". Neovim also seeks to enable embedding the editor within GUI applications.

The Neovim logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.

founded 3 years ago
MODERATORS